DEV Community

Discussion on: What is the simplest code to explain a loop?

Collapse
 
yaser profile image
Yaser Al-Najjar

Another guy came up with this:

speedometer = 0
while (speedometer <= 220):
    print("car speed is", speedometer)
    speedometer += 1

And then we can go into and operator with:

speedometer = 0
hold_in_gas = True
while (speedometer <= 220 and hold_in_gas):
    print("car speed is", speedometer)
    speedometer += 1