Decrementing for loops [duplicate] Decrementing for loops [duplicate] python python

Decrementing for loops [duplicate]


a = " ".join(str(i) for i in range(10, 0, -1))print (a)


Check out the range documentation, you have to define a negative step:

>>> range(10, 0, -1)[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]


You need to give the range a -1 step

 for i in range(10,0,-1):    print i