Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active July 23, 2020 00:38
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/f2edb9fa82aba0c0786d0b45d27cea3b to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/f2edb9fa82aba0c0786d0b45d27cea3b to your computer and use it in GitHub Desktop.
#List
a=[1,2,3,4,5]
#Converting iterable(list) to iterator object using iter() function
b=iter(a)
print (b)#Output:<list_iterator object at 0x00C8E658>
print (type(b))#Output:<class 'list_iterator'>
#Applying next() over the iterator.
#Returns one element at a time.
print (next(b))#Output:1
print (next(b))#Output:2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment