Sort integers in String
Coding Problem Keys
Sort integers in String
Problem Statement
The program must accept a string S which has only numbers and underscores in it as the input. The program must print only the integers present in the string S sorted in ascending order.Boundary Condition(s)
2 <= Length of the string S <= 100Input Format
The first line contains the value of string S.Output Format
The first line contains the list of numbers sorted in ascending order.Example Input/Output 1
Input
15_17_185_76_3_61Output
3 15 17 61 76 185
Example Input/Output 2
Input
_5_98_15_17_185_76_3_61_Output
3 5 15 17 61 76 98 185Max Execution Time Limit: 5000 millisecs
Solution
Programming Language: Python 3 Language
l=[]
for i in input().split("_"):
if i.isnumeric():
l.append(int(i))
print(*sorted(l))
# Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments