Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import collections
- def flatit(obj):
- mas = []
- if (isinstance(obj, str) and (len(obj) == 1)):
- mas.append(obj)
- elif (isinstance(obj, collections.Iterable)):
- for i in obj:
- mas += flatit(i)
- else:
- mas.append(obj)
- for j in mas:
- yield j
Advertisement
Add Comment
Please, Sign In to add comment