Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Recursive extend solution in Clear category for Flatten a List by adamspj
from collections.abc import Iterable
def flat_list(array: list[int]) -> Iterable[int]:
result = []
for item in array:
if isinstance(item, int):
result.append(item)
else:
result.extend(flat_list(item))
return result
March 5, 2024
Comments: