summaryrefslogtreecommitdiff
path: root/comp/work/47/flatten.py
diff options
context:
space:
mode:
authorthing1 <thing1@seacrossedlovers.xyz>2025-03-12 11:30:18 +0000
committerthing1 <thing1@seacrossedlovers.xyz>2025-03-12 11:30:18 +0000
commitfed4285a51b874113c41d9a9e78810640d71e5dc (patch)
tree1ad99a238c1d3b59be90a6a9728bb81930ab1c16 /comp/work/47/flatten.py
parent2ac42fa825d403e6285a58e08a62e6d549c86fa1 (diff)
to much work
Diffstat (limited to 'comp/work/47/flatten.py')
-rw-r--r--comp/work/47/flatten.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/comp/work/47/flatten.py b/comp/work/47/flatten.py
new file mode 100644
index 0000000..2e1958c
--- /dev/null
+++ b/comp/work/47/flatten.py
@@ -0,0 +1,10 @@
+def flatten(l):
+ out = []
+ for i in l:
+ if hasattr(i, "__len__"):
+ for j in flatten(i): out.append(j)
+ else: out.append(i)
+
+ return out
+
+print(flatten([1, [[4, 6], 5], 2]))