Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Iterable
- def allanar_coleccion(elementos, tipos_omitidos=(bytes, str)):
- for elmt in elementos:
- if isinstance(elmt, Iterable) and not isinstance(elmt, tipos_omitidos):
- yield from allanar_coleccion(elmt)
- else:
- yield elmt
- elementos = [[1,'a',['cat'],2],[[[3]],'dog'],4,5]
- for elmt in allanar_coleccion(elementos):
- print(elmt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement