Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. """Please write recursive function, that take nested list and return flat list."""
  2. def make_flat(l):
  3. if len(l) == 0:
  4. return []
  5. head,tail=l[0],l[1:]
  6. if isinstance(head, list):
  7. return make_flat(head) + make_flat(tail)
  8. else:
  9. return [head]+make_flat(tail)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement