Write a program to move numbers to the end of a string


Topic: Write a program to move numbers to the end of a string

Solution

str1 = 'hi 123 how are you doing? 567 is with you. Take care of 89'
  
res = '' 
dig = '' 
for ele in str1: 
    if ele.isdigit(): 
        dig += ele 
    else: 
        res += ele 
  
res += dig 
print("Strings after digits at end : " + str(res))



List all Python Programs