0
Question is about for loops and range
In for loops if we give command For i in range(1,-10,2) and print i These shows no output .why
3 Answers
0
This is because you are using a descending loop. The first number in the range should be less than the second number. But you have 1 greater than -10.2. To display the numbers in descending order, use slices.
0
Poorvik AS
In addition to Mila suggestion, you can also use negative step value to run the loop in reverse order.
For example:
for i in range(1, -10, -1):
print(i)