Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 23, 2020 01:19
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/38953c1966d3982df840af043cf0f32e to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/38953c1966d3982df840af043cf0f32e to your computer and use it in GitHub Desktop.
#dictionary
a={'a':1,'b':2,'c':3}
#Converting dictionary(iterable) into iterator object using iter() function.
b=iter(a.items())
print (b)#Output:<dict_itemiterator object at 0x01398F50>
print (type(b))#Output:<class 'dict_itemiterator'>
#Applying next() over the iterator.
#Returns one element(key,value) a time.
#Loops over the (key,value) pairs in the dictionary
print (next(b))#Output:('a', 1)
print (next(b))#Output:('b', 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment