Created
October 3, 2019 14:47
-
-
Save kabirahuja2431/63aad4d88bc17f8212902cff6de205b2 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**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