Skip to content

Commit 06ce0ab

Browse files
authored
Update genericRoutines.py
1 parent a98e258 commit 06ce0ab

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

genericRoutines.py

+15
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,18 @@ def find_index(x, lst):
218218
return k
219219
k +=1
220220
return -1
221+
222+
223+
224+
###flatten any dimension list
225+
226+
def flatten(items):
227+
for x in items:
228+
if isinstance(x, list):
229+
for sub_x in flatten(x):
230+
yield sub_x
231+
else:
232+
yield x
233+
234+
235+
print(list(flatten([1,2,3,[4,5,[6,7]]])))

0 commit comments

Comments
 (0)