Skip to content

Commit 368c1f0

Browse files
committed
Merge pull request yasoob#72 from SanketDG/mapfix
map returns an iterator in python3, use list. Fixes yasoob#65
2 parents 66a4cf1 + db979f1 commit 368c1f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

map_&_filter.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Here you go:
3333
.. code:: python
3434
3535
items = [1, 2, 3, 4, 5]
36-
squared = map(lambda x: x**2, items)
36+
squared = list(map(lambda x: x**2, items))
3737
3838
Most of the times we use lambdas with ``map`` so I did the same. Instead
3939
of a list of inputs we can even have a list of functions!
@@ -47,7 +47,7 @@ of a list of inputs we can even have a list of functions!
4747
4848
funcs = [multiply, add]
4949
for i in range(5):
50-
value = map(lambda x: x(i), funcs)
50+
value = list(map(lambda x: x(i), funcs))
5151
print(value)
5252
5353
# Output:

0 commit comments

Comments
 (0)