Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 5, 2020 04:01
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 IndhumathyChelliah/bd5e0eef629ca42cb1c8dc8de5cb1ac7 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/bd5e0eef629ca42cb1c8dc8de5cb1ac7 to your computer and use it in GitHub Desktop.
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