Skip to content

Instantly share code, notes, and snippets.

@kabirahuja2431
Created October 3, 2019 14:47
Show Gist options
  • Save kabirahuja2431/63aad4d88bc17f8212902cff6de205b2 to your computer and use it in GitHub Desktop.
Save kabirahuja2431/63aad4d88bc17f8212902cff6de205b2 to your computer and use it in GitHub Desktop.
def square(x):
return x**2
itr1 = range(5)
for i in itr1:
print(i)
'''
Prints
0
1
2
3
4
'''
#Using map
itr2 = map(square, itr1)
for i in itr2:
print(i)
'''
Prints
0
1
4
9
16
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment