Created
September 14, 2020 14:57
-
-
Save BetterProgramming/96e0eb465fd78af79bcdb80c327261d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def square(x): | |
return x*x | |
num=[1,2,3,4] | |
s=map(square,num) | |
#Returns a map object | |
print (s)#Output:<map object at 0x0158E4D8> | |
print (type(s))#Output:<class 'map'> | |
#converting map object to list() constructor. | |
print (list(s))#Output:[1, 4, 9, 16] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment