Logic Building
# Print numbers 10 to 1
for i in range(10, 0, -1):
print(i)Output
10 9 8 7 6 5 4 3 2 1
Use range with negative step.
Key Concepts:
- range(10, 0, -1) counts backwards
- Start: 10, End: 0 (exclusive), Step: -1
- Prints 10, 9, 8, ..., 1
Print numbers from 10 down to 1.
# Print numbers 10 to 1
for i in range(10, 0, -1):
print(i)10 9 8 7 6 5 4 3 2 1
Use range with negative step.