python dict get index

Solutions on MaxInterview for python dict get index by the best coders in the world

showing results for - "python dict get index"
Vincenzo
07 May 2017
1i = {
2	'foo':'bar',
3	'baz':'huh?'
4}
5
6#in python 3, you'll need to cast to list:
7# keys = list(i.keys())
8
9keys = i.keys()
10values = i.values()
11
12print(keys[values.index("bar")])
13# output: 'foo'