+ 1
Why does it ouput it whithout list function
When i use the list function, it outputs right. But without list, it outputs memory location. Why? https://code.sololearn.com/cvGVy6IpT4HD/?ref=app
8 Antworten
+ 4
Nabeer Chowdhury ,
using map generates a map object as output
the most common way to solve this task, is to use list() at the place where the map object is created:
numbers = [1,2,3,4,5]
a = list(map(lambda x: x+5, numbers))
print(a)
an other way would be to use a list comprehension:
numbers = [1,2,3,4,5]
print([ num + 5 for num in numbers])
+ 2
Would u be kind enough to provide a link where i can learn in details... also its something new u showed me. Appreciate that ^_^
+ 1
Did and why is that
+ 1
You can also try this, it will convert map object into list:
print(list(a))