drag to orbit Β· scroll to zoom
← Playground

🎠 Carousel · while

Watch count below: every time the carousel goes around, count drops by 1. Watch the loop nibble it down to 0.

Variable tracker
count = 3
count > 0 β†’ True (music playing, keep spinning)
Press "Spin" β€” the carousel stops only when count = 0
Python code
count = 3 while count > 0: spin_once() count = count - 1 # count=0 β†’ False, exit loop

πŸ’‘ while has no idea how many turns it will take β€” it only checks the condition: keep going while it is True, stop the moment it turns False. (If you can count the turns ahead of time, use a for loop β€” that's the conveyor belt.)