What i have understood so far from the map function is that it applies a given function to each item in an iterable and returns the list of the result.
def square(num):
return num**2
list_num = [1,2,3,4]
considering the above function and the list of numbers as an example.
if we: list(map(square,list_num))
we will get as an output [1,4,9,16]
.
now comes the part that i am not able to find a sensible explenation of, if i
print(map(square,list_num))
i will get as an output <map object at 0x038B0290>
.
My question is, Why am i getting the memory location and not a list when i use the print()
function or when use map(square,list_num)
.