Answer to Question #312892 in Python for venu

Question #312892

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)


1
Expert's answer
2022-03-17T06:42:28-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS