Say I have this data:
data = [{'name': "Name 1", 'value': None}, {'name': "Name 2", 'value': None}, {'name': "Name 3", 'value': None}]
How can I assign three variables based on this data, given that each time the code is run, the dicts may be shuffled. Meaning that "Name 1" could potentially be found in either index 0, 1 or 2.
I did try this:
for x in data:
if x['name'] == 'Name 1':
a = x['value']
continue
if x['name'] == 'Name 2':
b = x['value']
continue
if x['name'] == 'Name 3':
c = x['value']
continue
But I find this rather ugly. Is there a better, more Pythonic way?
a, b, c = ??