0
why map in python...?
Look at this code: iLiSte=[19,868,30495,334,2] print(list(map(lambda x:x-1,miLiSte))) #output [18, 867, 30494, 333, 1] And look now: miLiSte=[19,868,30495,334,2] print(map(lambda x:x-1,miLiSte)) #output <map object at 0x02F7D330> why map return a direction,i think it is, if i dont make it list?
2 Respuestas
+ 5
The map() function returns a map object in python 3. A map object is iterable and can be converted into another iterable type such as list() or tuple(), but it is not necessary if you just need to iterate over the elements of the map object. You can also unpack it with the unpacking operator '*' like any other iterable.
+ 2
Oh i think i get it, thank you very much