Rearrange Numbers in String
Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with the decimal part.
The input will be a single line containing a string.
The output should be a single line containing the modified string with all the numbers in the string re-ordered in decreasing order.
For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".
Sample Input
I am 5 years and 11 months old
Sample Output
I am 11 years and 5 months old
Sample Input
I am 17 I want 18 but 20or24 ok
Sample Output
I am 24 I want 20 but 18or17 ok
Sample Input
I have learnt 3% of Python 4 for 45 days
Sample Output
I have learnt 45% of Python 4 for 3 days
Comments
sample input 2 and 3 are not working
Leave a comment