If I had a method that got me a rate based on a keys values, and I wanted to order them from lowest to highest. How would I associate the new values with the original keys?
This is a hypothetical
CodePudding user response:
I don't think your desired output is valid: the parentheses here ('id': 1, data: [478, 490, 9087, 2909, 890, 2790 '478'])
suggest that this object is a tuple, but the colons make it seem like a dictionary.
Maybe you're really looking for something like this?
{
'Manchester': {'id': 1, data: [478, 490, 9087, 2909, 890, 2790 '478']},
...
}
In which case, how about something like this for your last line?
data[key] = { 'id': value_1, 'data': [value_2, value_3, value_4, value_5, value_6, value_7] }
CodePudding user response:
Where you have
data[key] = (value_1, value_2, value_3, value_4, value_5, value_6,
value_7)
You'll want to update it to the following:
data[key] = {
'id': value_1,
'data': [value_2, value_3, value_4, value_5, value_6, value_7]
}