Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active July 23, 2020 01:18
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/36fa0a555e5adfb8520962f44a2f3263 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/36fa0a555e5adfb8520962f44a2f3263 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.values())
print (b)#Output:<dict_valueiterator object at 0x012F3BE0>
print (type(b))#Output:<class 'dict_valueiterator'>
#Applying next() over the iterator.
#Returns one element(values) a time.
#Loops over the values in the dictionary
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