Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. def alphabet_position(text):
  2. alphabet_dict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8,'i':9,'j':10,
  3. 'k':11,'l':12,'m':13,'n':14,'o':15,'p':16,'q':17,'r':18,'s':19,'t':20,'u':21,
  4. 'v':22,'w':23,'x':24,'y':25,'z':26}
  5. # makes text into list
  6. text_list = [letter for letter in text]
  7. new_list = []
  8.  
  9. # looks for the letter in the dict
  10. for letter in text.lower():
  11. if letter in alphabet_dict:
  12. new_list.append(alphabet_dict.get(letter))
  13. #text.replace(letter, str(alphabet_dict.get(letter)))
  14. elif letter not in alphabet_dict:
  15. continue
  16.  
  17.  
  18. return ' '.join([str(x) for x in new_list])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement