brucemartineau8475
27.02.2020 •
Computers and Technology
Write the recursive function flat(aList) that takes a possibly deep list and flattens it. The function should not mutate the original list. Hint: you can check if something is a list by using the built-in functions type() or isinstance [3, [[5, 2, 6, [4]] >>>X flat (x) [3, 5, 2, 6, 4] >>>X [3, [[5, 2, 6, [4]]
Solved
Show answers
More tips
- F Food and Cooking Pu-erh Tea: History, Varieties, Benefits, and Risks...
- H Health and Medicine How to Whiten Teeth and Get the Perfect Smile...
- F Food and Cooking How to Make Thin Pancakes: Recipe and Tips...
- S Style and Beauty Is Hot Scissor Haircutting Beneficial or Dangerous?...
- S Style and Beauty How to Get Rid of Under Eye Bruises?...
- F Food and Cooking Is Bacon Good for You?...
- S Style and Beauty Discover the Art of Nail Design: How Do You Paint Your Nails?...
- P Philosophy How to Develop Extrasensory Abilities?...
- O Other Everything You Need to Know About Kudyabliks...
- C Computers and Internet The Twitter Phenomenon: What it is and How to Use it...
Answers on questions: Computers and Technology
- M Mathematics Jonathan has a comic book collection. He tells you he sold half of them, but then bought 12 more new comics. After this, Jonathan now has 90 comic books. How many...
- S Spanish ¿Carlos les describe la tarea a Ana y a ti?...
- M Mathematics Use the point-slope formula to write an equation of the line that passes through (-5,3) and (4,6). write the answer in slope-intercept form (if possible)....
Ответ:
There is an attachment below
Explanation:
CODE
def flat(aList):
if aList == []:
return aList
if isinstance(aList[0], list):
return flat(aList[0]) + flat(aList[1:])
return aList[:1] + flat(aList[1:])
x = [3, [[5, 2]], 6, [4]]
print(x)
print(flat(x))
Ответ:
hyy sure we can talk ig