Reverse the equation



Problem to reverse the given equation.



Example-1:


Input    : s = "30*5+12"
Output   : 12+5*30 


Example-2:


Input    : s = "250-73/45+68*3"
Output   : 3*68+45/73-250







Solution




import re

s = "30*5+12"

l = []

k = []

r = re.findall(r"[0-9]+",s)

r = r[::-1]

for x in s:

    if(not(x.isdigit())):

        l.append(x)

l = l[::-1]

for i in range(len(l)):

    k.append(r[i])

    k.append(l[i])

k.append(r[-1])

k = "".join(k)

print(k)



Output



12+5*30