Jan-06-2018, 03:46 AM
Hello,
I'm very new to Python (and coding overall) and am taking my first course. Currently writing a function that takes a letter, space, or empty string as a parameter and returns the number in which it appears on a standard phone number pad:
Thanks for helping a newbie!
I'm very new to Python (and coding overall) and am taking my first course. Currently writing a function that takes a letter, space, or empty string as a parameter and returns the number in which it appears on a standard phone number pad:
phone_letters = [" ", "", "ABC", "DEF", "GHI", "JKL", "MNO", "PQRS", "TUV", "WXYZ"] def let_to_num(letter): key = 0 while key < 10: if str(letter) in phone_letters[key]: return key else: key = key + 1 let_to_num(" ") let_to_num("g") let_to_num("M") let_to_num(5)When I run this code block I receive nothing in return. When I remove the last line (let_to_num(5)) I receive 6 as the only output. Can anyone tell me what needs to be fixed?
Thanks for helping a newbie!