Answer to Question #176604 in Python for adhi chinna

Question #176604

Shift Numbers

Given a string, write a program to move all the numbers in it to its end.Input


The input will contain a string A.Output


The output should contain a string after moving all the numbers in it to its end.Explanation


For example, if the given string A is "1good23morning456," the output should be "goodmorning123456," as it contains numbers at the end.




1
Expert's answer
2021-04-04T11:15:17-0400
# get the string from the user
inputString =input("");
digits=""
letters=""
symbols=""
# Looping through a string.
for letter in inputString:
    if (letter.isdigit()):
        digits+=letter
    elif (letter.isalpha()):
        letters+= letter
    else:
        symbols+= letter
# Display a new string.
print(letters+digits+symbols)

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