Advertisement
fumanbest

Decipher this!

Feb 22nd, 2020
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. text = input().split()
  2.  
  3.  
  4. def swap(c, i, j):
  5.     c = list(c)
  6.     c[i], c[j] = c[j], c[i]
  7.     return "".join(c)
  8.  
  9.  
  10. for key in text:
  11.     list_zero = []
  12.     list_element = []
  13.     if key == text[0]:
  14.         [list_zero.append(i) for i in key if i.isdigit()]
  15.         num = int("".join(list_zero))
  16.         num = chr(num)
  17.         list_element.insert(0, num)
  18.         [list_element.append(j) for j in key if not j.isdigit()]
  19.  
  20.         print(swap(list_element, 1, - 1), end=" ")
  21.         list_zero.clear()
  22.         list_element.clear()
  23.  
  24.     elif key == text[1]:
  25.         [list_zero.append(i) for i in key if i.isdigit()]
  26.         num = int("".join(list_zero))
  27.         num = chr(num)
  28.         list_element.insert(0, num)
  29.         [list_element.append(j) for j in key if not j.isdigit()]
  30.  
  31.         print(swap(list_element, 1, - 1), end=" ")
  32.         list_zero.clear()
  33.         list_element.clear()
  34.  
  35.     elif key == text[2]:
  36.         [list_zero.append(i) for i in key if i.isdigit()]
  37.         num = int("".join(list_zero))
  38.         num = chr(num)
  39.         list_element.insert(0, num)
  40.         [list_element.append(j) for j in key if not j.isdigit()]
  41.  
  42.         print(swap(list_element, 1, - 1), end=" ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement