Update u3/flatten_array.py
This commit is contained in:
parent
c9ca31a83b
commit
354ffbcd8d
@ -2,9 +2,9 @@ def flatten(iterable):
|
||||
result = []
|
||||
for item in iterable:
|
||||
if isinstance(item, (list, tuple)):
|
||||
# Якщо елемент є списком або кортежем — викликаємо flatten рекурсивно
|
||||
# is the element is a list or a tuple, we call 'flatten' recursively /// Ak je prvok zoznamom alebo tupľom, voláme funkciu flatten rekurzívne
|
||||
result.extend(flatten(item))
|
||||
elif item is not None:
|
||||
# Додаємо елемент лише якщо він не None
|
||||
# pridame prvok len vtedy, ak nie je None /// add an element only if it is not None
|
||||
result.append(item)
|
||||
return result
|
||||
Loading…
Reference in New Issue
Block a user