Answer to Question #316220 in Python for shift numbers 2

Question #316220

shift numbers -2






given a string, write a program to move all the numbers in it to its start.






input






the input will contain a string A.






output






the output should contain a string after moving all the numbers in it to its start.






explanation






for example, if the given string A is "1good23morning456",the output should be "123456goodmorning",as it contains numbers at the start.






sample input 1






1good23morning456






sample output 2






123456goodmorning






sample input 2






com876binat25ion






sample output 2






87625combination

1
Expert's answer
2022-03-22T19:07:53-0400
line = input()
numbers = ''
rest = ''
digits = '1234567890'


for ch in line:
    if ch in digits:
        numbers += ch
    else:
        rest += ch
result = numbers + rest
print(result)

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