top of page
Search

PYTHON CODING

  • Writer: waclaw_koscielniak
    waclaw_koscielniak
  • Jul 23
  • 1 min read

def flatten(lst):

for item in lst:

if isinstance(item, list):

yield from flatten(item)

else:

yield item

print(list(flatten([1, [2, [3, 4], 5]])))


[Running] python3 -u "/Users/name/test/test101.py"

[1, 2, 3, 4, 5]

[Done] exited with code=0 in 0.052 seconds

Try to run it.
Try to run it.

 
 
 

1 Comment


Guest
Jul 23

Did you try to run it?

Like
bottom of page