Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 23, 2020 05:05
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/0a04c083876c788ad8328c09587aad11 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/0a04c083876c788ad8328c09587aad11 to your computer and use it in GitHub Desktop.
l1=[1,2,3]
l2=iter(l1)
#Converting iterator to list using list() constructor
print (list(l2))#Output:[1,2,3]
#Returns zero because iterator is exhausted and can't be used again.
#If u want to do something different with the same stream, you'll have to create a new iterator.
print (sum(l2))#Output:0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment