How to access part of a dictionary in python?
So I have a dictionary which consists of numbers matched with a word. I
want to be able to access part of the dictionary based on what the user
enters.
How do I make it so that if the user enters a number, e.g. "2", the
program picks the item from the dictionary that matches "2" and prints it?
or if the user enters "hydrogen" (a word in the dictionary) it needs to
print its corresponding number ("1").
Thanks in advance
No comments:
Post a Comment