Decrementing for loops

pandoragami picture pandoragami · Jan 22, 2011 · Viewed 162.1k times · Source

I want to have a for loop like so:

for counter in range(10,0):
       print counter,

and the output should be 10 9 8 7 6 5 4 3 2 1

Answer

user225312 picture user225312 · Jan 22, 2011
a = " ".join(str(i) for i in range(10, 0, -1))
print (a)