Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 21, 2020 05:43
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/bad386bbfcedca602aa4bd63aecd99c8 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/bad386bbfcedca602aa4bd63aecd99c8 to your computer and use it in GitHub Desktop.
g=(n for n in range(1,11) if n%2==0)
print (g) #Output: <generator object <genexpr> at 0x0116C728>
#We can loop through generator object.
for i in g:
print (i, end=" ") #Output: 2 4 6 8 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment