title: Python 2.7 Convert Letters to Phone Numbers
body: <p>I am trying to complete a code that converts letters into a phone number sequence. What I need is to make for example JeromeB to 537-6632. Also I need the program to cut off the letter translation after the last possible digit. So for example after 1-800-JeromeB even if I write in 1-800-JeromeBrigham it will not code that. The thing is though I do not understand how to implicate that into my code. I do not know understand to cut off the last letter and put in the dash. What I currently have is this</p>
  
  <pre><code>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 ').lower()
  
  s = ""
  for index in range(len(phone)):
      if phone[index].isalpha():
          s = s + str(num[alph.index(phone[index])])
      else:
          s = s + phone[index]
  print s  
  </code></pre>