Joan Venge Joan Venge - 1 year ago 99
Python Question

Loop backwards using indices in Python?

I am trying to loop from 100 to 0. How do I do this in Python?

for i in range (100,0)
doesn't work.

Answer Source

Try range(100,-1,-1), the 3rd argument being the increment to use (documented here).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download