Jul-06-2020, 01:36 PM
That line is easy to read
This approach is usually what i have used for this,can also trow in a
This approach is usually what i have used for this,can also trow in a
yield from
(new in Python 3.3) to make it a little cooler.def flatten(seq): for item in seq: if isinstance(item, list): yield from flatten(item) else: yield item mylist = ["Hello", ["Hello2", "Hello3"], "Hello4"] print(list(flatten(mylist)))
Output:['Hello', 'Hello2', 'Hello3', 'Hello4']