Answer to Question #312003 in Python for mahesh

Question #312003

reorder of string

eren wants to modify a string. the string can contain only positive integers. he wants to change the string in such a way thet the smaller numbers should appear before the bigger numbers.


given string write a program to help eren to modify the string.


1
Expert's answer
2022-03-15T12:12:14-0400
import re
input1 = input('')
numbers = tuple(sorted(map(int, re.findall(r'([\d]+)', input1)), reverse=True)) 
inpPlaceholders = re.sub(r'([\d]+)', '%s', input1) 
print(inpPlaceholders % 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