reorder the string.eren wants to modify a string.the string can contain only positive integers.he wants to change the string in such a way that the smaller numbers should appear before the bigger numbers.given a string write a program to help eren to modify the string
list1 = []
list2 = []
list3 = []
j = 0
string = ''
input1 = input()
for i in input1:
if i.isdigit() == True:
list1.append(i)
list2.append(input1.index(i))
zp = list(zip(list1,list2))
zp.sort()
for i in zp:
list3.append(i[0])
for i in input1:
if i.isdigit() == True:
string = string + list3[j]
j = j+1
else:
string = string + i
string
'my124'
Comments
Leave a comment