Python Program to Move all the Numbers in String to its end

 

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.

Sample Input 1
com876binat25ion

Sample Output 1
combination87625

Code:

word=input()
char=""
digits=""
for i in word:
    if i.isdigit():
        digits+=i
    else:
        char+=i
print("{}{}".format(char,digits))

Input

Output

Comments

Popular posts from this blog

CODING ASSIGNMENT 4

CODING PRACTICE 11 Music Page

CCBP Static Website Coding Assignment 2 Solution | Yoga Page