I have a dictionary with one key and two values and I want to set each value to a separate variable.
d= {‘key’ : (‘value1, value2’),
‘key2’ : (‘value3, value4’),
‘key3’ : (‘value5, value6’)}
I tried d[key][0] in the hope it would return “value1” but instead it return “v”
Any suggestions?
A better solution is to store your value as a two-tuple:
That way you don’t have to split every time you want to access the values.