Access an arbitrary element in a dictionary in Python
On Python 3, non-destructively and iteratively: next(iter(mydict.values())) On Python 2, non-destructively and iteratively: mydict.itervalues().next() If you want it to work in both Python 2 and 3, you can use the six package: six.next(six.itervalues(mydict)) though at this point it is quite cryptic and I’d rather prefer your code. If you want to remove any item, do: … Read more