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.
# 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)
Comments
Leave a comment