While - Else

With the else statement we can run a block of code once when the condition no longer is true:


i = 1 
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")




© 2025 Better Solutions Limited. All Rights Reserved. © 2025 Better Solutions Limited TopPrev