So, for an assignment I would have to take user input such as 1146 and then get python to convert it to “one one four six”
So far I start with the dictionary
dict = { 1:"one", 2:"two", 3:"three", 4:"four", 5:"five",
6:"six", 7:"seven", 8:"eight", 9:"nine"};
then ask for inout
x = raw_input(("enter number: "))
y = x.split
I want to know how or if dict[y] could take a variable such as when y is split after user inputs it. Can anyone help?
You can’t index into a dict using a list, but you could use a loop, list comprehension or generator expression. Something like this: