I tried really hard on this one, finally came up with this, however, there's space between every number in my result because of the code 'print xxx,' , I want to find a way to delete those spaces.
Program: let user enter say 555-GET-FOOD, convert it to 555-438-3663
alph = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',\ 'q','r','s','t','u','v','w','x','y','z'] num =[2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9] phone = raw_input('enter phone number in the format xxx-xxx-xxxx ').lower() index = 0 for index in range(len(phone)): if phone[index].isalpha(): print num[alph.index(phone[index])], else: print phone[index],
this is a very intro python course, I did some reasearch online, people using dictionary and enu something or join that we never covered in class. besides the code I used in my program, I was trying to use 'replace', but failed.
It took me hours to came up with the code I already have but I want to make it perfect without the spaces, so any help will be appreciated.