Question #189178

n = input().split()
d=[]
z = []
for i in n:
    if (i.isdigit()):
        if (int(i) > 0):
            print(i)
            z = z + [i]
            c = n.index(i)
            d.append(c)
d.sort(reverse = True)

for i in range(len(d)):
    n[d[i]] = z[i];

m = ""
for i in n:
    m = m + i + " "
print(m)

what is wrong in this code, please explain it. sir


Expert's answer

As far as I see, there is nothing wrong. The code takes a string with numbers and reverses the order of these numbers. If it is not the behaviour that your expect, please, tell more specifically what you want to achieve.


LATEST TUTORIALS
APPROVED BY CLIENTS