Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python3 problem. please attatch the screen shot and copy the code please. thank you so much Problem A: Flatten List (10 points) As you know,

python3 problem. please attatch the screen shot and copy the code please. thank you so much

image text in transcribed

Problem A: Flatten List (10 points) As you know, lists in Python can contain objects of any kind. It is possible, therefore, to have a list which contains another list-a nested list. You may even have a list like where the elements are nested multiple times, and in no sensible order. Your assignment is to write a recursive function, flattenList (alist), that returns a flattened" version of any given list. That is, all elements (not including lists) of the given list should be in the final, non-nested list in their original order. For example, if the above list was the input, your function should return 1, 4, 2, 5, 31 Your program does not need a main. You do not need to prompt for input from the user; just write the function, and all testing on our part will be done by calling your function with parameters we have defined. Of course, you may test your program however you like. Constraints The name of your function must be flattenList (this makes testing easier for us) Your function must be pure; i.c., it should not mutate the input object at all, and may not use print statements Your function must be recursive (loops are not allowed) You may not import any modules

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

Students also viewed these Databases questions