I would like to translate items in a list (e.g. [1,2,3,4,5,6,7,8,9]) to items in another list (e.g. the names of those numbers).
Furthermore, I want to be able to do the translation so that when a user inputs ‘1’, “one” is printed, and similarly for ‘2’, etc.
Here’s the code I have so far:
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
names = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',
'eight', 'nine']
myDict = dict(zip(numbers, names))
Using the
inputfunction will allow you to accept input from the user and do the lookup (if I understand what you are asking):