printing sentence in decreasing order based on number
example
input= It took 13days 14nights to reach delhi by walk
output=It took 14days 13nights to reach delhi by walk (as decreasing order is 14,13 just numbers got replaced not word)
import re
input1 = input('')
numbers = tuple(sorted(map(int, re.findall(r'([\d]+)', input1)), reverse = True))
res = re.sub(r'([\d]+)', '%S', input1)
print(res % numbers)
Comments
Leave a comment