BdW44222

08.Decipher This

Jul 4th, 2021
970
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def replace_character_code(word: str):
  2.     chr_code_str = ''
  3.     new_word = []
  4.  
  5.     for ch in word:
  6.         if ch.isnumeric():
  7.             chr_code_str += ch
  8.         else:
  9.             new_word.append(ch)
  10.  
  11.     ch_at_beginning = chr(int(chr_code_str))
  12.  
  13.     new_word.insert(0, ch_at_beginning)
  14.  
  15.     return new_word
  16.  
  17.  
  18. def decipher_word(word: str):
  19.     new_word = replace_character_code(word)
  20.  
  21.     new_word[1], new_word[-1] = new_word[-1], new_word[1]
  22.  
  23.     return "".join(new_word)
  24.  
  25.  
  26. words = input().split()
  27.  
  28. deciphered_words = [decipher_word(word) for word in words]
  29.  
  30. print(' '.join(deciphered_words))
  31.  
RAW Paste Data