In the image attached, when i=3, why does the "break" take us to the final print("Out side the loop")
? Why doesn't it jump to the part:
else:
print ("Loop terminates with success")?
I am struggling to understand this.
In the image attached, when i=3, why does the "break" take us to the final print("Out side the loop")
? Why doesn't it jump to the part:
else:
print ("Loop terminates with success")?
I am struggling to understand this.
for...else
loops only run the else
when the loop terminates normally and a break
is not encountered. So, it skips the else
since the loop was ended early.