Noob here. I'm making two HTTP requests and saving the results to variables. Both requests return a JSON array of objects, which I then parse, resulting in two separate dictionary variables. So something like this:
first_dict = {
0: {
important_key: 3333
},
...
}
second_dict = {
0: {
important_key: 4444
},
...
}
I need to create a new variable that contains the first entry from one of the dictionaries, depending on which of the two candidates has the lowest number for `important_key`. How would I go about doing this?
I thought about merging the two dictionaries and sorting them by that key, but was unclear how to do that. I also thought about creating two new variables, each containing the first entry in its respective dictionary, and then trying to use a conditional to select between them, but again I'm so green I'm having trouble figuring out how to do that.
Help anyone?
first_dict = {
0: {
important_key: 3333
},
...
}
second_dict = {
0: {
important_key: 4444
},
...
}
I need to create a new variable that contains the first entry from one of the dictionaries, depending on which of the two candidates has the lowest number for `important_key`. How would I go about doing this?
I thought about merging the two dictionaries and sorting them by that key, but was unclear how to do that. I also thought about creating two new variables, each containing the first entry in its respective dictionary, and then trying to use a conditional to select between them, but again I'm so green I'm having trouble figuring out how to do that.
Help anyone?