Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created September 14, 2020 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/96e0eb465fd78af79bcdb80c327261d5 to your computer and use it in GitHub Desktop.
Save BetterProgramming/96e0eb465fd78af79bcdb80c327261d5 to your computer and use it in GitHub Desktop.
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