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