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

27th Sep 2021, 10:59 PM
Jenkins
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
27th Sep 2021, 11:10 PM
Simon Sauter
Simon Sauter - avatar
+ 2
Outer loop - i starts from 0 to 9. So outer loop executes 10times
28th Sep 2021, 2:00 AM
Parith (Faree)
Parith (Faree) - avatar