0
Please I need help to understand this loop range code
x = 0 for i in range(10): for j in range(-1, -10, -1): x += 1 print(x) Why does the outer loop iterate 10 times and not 9 times for every iteration of the outer loop? It is because of the ‘x +=1’ on line 4
2 Respuestas
+ 2
In range the start is inclusive, the end exclusive.
Just take a look at this:
https://code.sololearn.com/cYggxHKOG5Sj/?ref=app
+ 2
Outer loop - i starts from 0 to 9. So outer loop executes 10times