+ 2

Map question

def a(x): return x+5 nums=[11,22,33,44,55] b = map(a,nums) print(b) >>> <map=0×010BA510> What's that output??

2nd Mar 2017, 12:42 PM
C.R.Devila
C.R.Devila - avatar
5 Answers
+ 3
No problem. Explanation: Because map is not a simple dictionary, list or anything like that, it cannot be displayed. When you try to print an object that is not any of those base types, it calls the __repr__ method, which is by default <fn=addres-in-memory>, but can also be overridden if necesarry.
2nd Mar 2017, 1:26 PM
DefaltSimon
DefaltSimon - avatar
+ 3
yeah, but the thing is a() is a function and map is a tuple...having an unusable/unused function in a tuple could explain that output
4th Mar 2017, 5:27 PM
KosT
KosT - avatar
+ 1
@DefaltSimon Thanks, but what I mean is what <map=0×010AB510> is? Can anyone tell me plz?
2nd Mar 2017, 1:19 PM
C.R.Devila
C.R.Devila - avatar
0
The reason this is happening is because you need to iterate over the list. A simple list(map(a, nums)) should also work.
2nd Mar 2017, 12:58 PM
DefaltSimon
DefaltSimon - avatar
0
add list()
2nd May 2017, 1:21 AM
onefineday