Advertisement
Guest User

decipher

a guest
Feb 22nd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. def int_to_chr(word):
  2.     string = list(word)
  3.     num_as_str = list()
  4.  
  5.     while string[0].isdigit():
  6.         num_as_str.append(string[0])
  7.         string.pop(0)
  8.  
  9.     num = int(''.join(num_as_str))
  10.     string.insert(0, chr(num))
  11.     return ''.join(string)
  12.  
  13.  
  14. def switch_letters(word):
  15.     letters = list(word)
  16.     letters[1], letters[-1] = letters[-1], letters[1]
  17.     return ''.join(letters)
  18.  
  19.  
  20. def decipher(word):
  21.     word = int_to_chr(word)
  22.     word = switch_letters(word)
  23.     return word
  24.  
  25.  
  26. print(' '.join([decipher(word) for word in input().split()]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement