0

Having a python dict

mydict= {'1': ['1', '2'], '1': ['2', '4'], '1': ['5', '6']

Knowing the unique value 1, i want to return the corresponding key. In this case '1'.

Using list(element_nodes.keys())[list(element_nodes.values()).index(1)] returns the Error message ValueError: '1' is not in list

Ideally i want to return the coressponding second value for this key. In this case [1, 2]

stp2058
  • 41
  • 5

0 Answers0