Quote:As a beginner, I have used a dictionary to ".get" one variable associated with a unique key.yes a for loop.
However, what if I need to .get 47 variables based on the two-letter unique key? Is that possible with a dictionary? Is it easy to grab/identify each variable with some kind of loop or something?
You can also just return a list of keys via MY_DICTIONARY.keys() and a list of values with MY_DICTIONARY.values()
If you need to specify the key and not get all you can just loop them and insert an if condition to get the key/value pairs you want
for k,v in MY_DICTIONARY.items(): #insert if condition here to check key for more filtering #k is the key #v is the value of that keyPost your code for more explicit help
Recommended Tutorials: