Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #every lowercase letter [a..z] is replaced with the corresponding one in [z..a]
- #every other character (including uppercase letters and punctuation) is left untouched.
- # That is, ‘a’ becomes ‘z’, ‘b’ becomes ‘y’, ‘c’ becomes ‘x’, etc. For instance, the word “vmxibkgrlm”, when decoded, would become “encryption”.
- #Write a function called answer(s) which takes in a string and returns the deciphered string
- from string import ascii_lowercase as alphabet
- def answer1(s):
- newlist = ''
- for element in s:
- if element in alphabet:
- position = alphabet.index(element)
- letter = alphabet[25 - position]
- newlist += letter
- else:
- newlist += element
- return ''.join(newlist)
- #test
- s = answer1("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p")
- print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement