Decreasing for loops in Python impossible?

Gal picture Gal · Nov 27, 2010 · Viewed 135k times · Source

I could be wrong (just let me know and I'll delete the question) but it seems python won't respond to

for n in range(6,0):
    print n

I tried using xrange and it didn't work either. How can I implement that?

Answer

Steve Tjoa picture Steve Tjoa · Nov 27, 2010
for n in range(6,0,-1):
    print n
# prints [6, 5, 4, 3, 2, 1]