Advertisement
go6odn28

decipher_8

Feb 17th, 2024
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. string_input = input().split(" ")
  2.  
  3. decipher_string_1 = []
  4. final_decipher_string = []
  5.  
  6. number = ''
  7. for word in string_input:
  8.     for char in word:
  9.         if char.isdigit():
  10.             number += char
  11.         else:
  12.             decipher_string_1.append(char)
  13.  
  14.     # find letter on the current number
  15.     letter = chr(int(number))
  16.     # insert letter in the beginning of string
  17.     decipher_string_1.insert(0, letter)
  18.     number = ''
  19.     # swap second and last letter
  20.     sec_letter = decipher_string_1[1]
  21.     last_letter = decipher_string_1[-1]
  22.     decipher_string_1[1] = last_letter
  23.     decipher_string_1[-1] = sec_letter
  24.     final_decipher_string.extend(decipher_string_1)
  25.     final_decipher_string.extend(' ')
  26.     decipher_string_1 = []
  27.  
  28. print(''.join(final_decipher_string))
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement