Advertisement
DiYane

Decipher this

Sep 25th, 2023
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. text = input().split()
  2.  
  3. def swap(c, i, j):
  4.     c = list(c)
  5.     x=c[i]
  6.     c[i], c[j] = c[j], x
  7.     return "".join(c)
  8.  
  9. res=[]
  10.  
  11. for key in text:
  12.     list_zero = []
  13.     list_element = []
  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.     res.append(swap(list_element, 1, - 1))
  21.     res.append(" ")
  22.     list_zero.clear();
  23.     list_element.clear();
  24.  
  25. res="".join(res)
  26. print(res)
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement