+ 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

12th Sep 2021, 10:09 PM
Nabeer Chowdhury
Nabeer Chowdhury - avatar
8 odpowiedzi
+ 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])
13th Sep 2021, 10:43 AM
Lothar
Lothar - avatar
+ 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 ^_^
12th Sep 2021, 10:20 PM
Nabeer Chowdhury
Nabeer Chowdhury - avatar
+ 1
Did and why is that
12th Sep 2021, 10:13 PM
Nabeer Chowdhury
Nabeer Chowdhury - avatar
+ 1
You can also try this, it will convert map object into list: print(list(a))
13th Sep 2021, 7:46 AM
Sousou
Sousou - avatar