Answer to Question #189178 in Python for Ganesh Karthikeyan

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


1
Expert's answer
2021-05-05T03:57:10-0400

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.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS