7.1k views
0 votes
Im trying to call the keys in a dictionary I have called "planet_dict". in order for them to be included in the for loop, the values of the keys have to be within a range of

273 <= x <= 373
I understand how to do this with certain values, but idk how to call them from a dictionary.

Im trying to call the keys in a dictionary I have called "planet_dict". in-example-1
User Duxa
by
5.5k points

1 Answer

4 votes

You can do something like this. My code iterates through the dictionary keys and then we use that key to get a value. We check if the value is between 273 and 373 and if it is, it's a water planet. My code is just a general idea of what to do. Instead of printing, you could add the key to a list and then print the contents of the list.

Im trying to call the keys in a dictionary I have called "planet_dict". in-example-1
User Ian Wise
by
5.0k points