-
-
Save IndhumathyChelliah/38953c1966d3982df840af043cf0f32e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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