diff --git a/snippets/deep_flatten.md b/snippets/deep_flatten.md index 349c1830d..7c6822bb3 100644 --- a/snippets/deep_flatten.md +++ b/snippets/deep_flatten.md @@ -10,6 +10,8 @@ Deep flattens a list. - If it is iterable, apply `deep_flatten()` recursively, otherwise return `[lst]`. ```py +from collections.abc import Iterable + def deep_flatten(lst): return ([a for i in lst for a in deep_flatten(i)] if isinstance(lst, Iterable) else [lst])