Skip to content

Commit 45dbb8f

Browse files
committed
alternative to flatten a list
shorter version using asterix
1 parent fabea4b commit 45dbb8f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

one_liners.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ is a simple example:
7171
a_list = [[1, 2], [3, 4], [5, 6]]
7272
print(list(itertools.chain.from_iterable(a_list)))
7373
# Output: [1, 2, 3, 4, 5, 6]
74+
75+
# or
76+
print(list(itertools.chain(*a_list)))
77+
# Output: [1, 2, 3, 4, 5, 6]
7478
7579
7680
**One Line Constructors**

0 commit comments

Comments
 (0)