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
import itertools | |
#lambda function and itertools.count() is given as argument in map()function. | |
l1=map(lambda x:x**2,itertools.count()) | |
#It returns a map object which is an iterator. | |
print(l1)#Output:<map object at 0x00E2E610> | |
#iterate thorugh map object using for loop | |
for i in l1: | |
if i>50: | |
break | |
else: | |
print (i ,end=" ")#Output:0 1 4 9 16 25 36 49 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment