From 93e0450af229431397f2b2bf5ad7a8e6fdb7e595 Mon Sep 17 00:00:00 2001 From: Trupil <66239182+trupil3@users.noreply.github.com> Date: Tue, 29 Dec 2020 23:23:45 +0530 Subject: [PATCH] Update deep_flatten.md --- snippets/deep_flatten.md | 2 ++ 1 file changed, 2 insertions(+) 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])