No Fluff Guide to Python - P12 - Loops

"History is about loops and continuum." while true : dispense(coldDrink_Can) Imagine you have a big box of toys: you want to go through each toy and play with it but instead of picking up each toy one by one, you want a way to play with all the toys without lifting them individually that's where loops in Python come in handy a loop is like a magical robot arm that helps you go through each toy in the box automatically it saves you time and effort. In Python: you can use a loop to repeat a set of instructions over and over again until a certain condition is met Example you can tell the loop to play with each toy in the box until there are no more toys left example: toys = [ "car" , "ball" , "doll" , "blocks" ] for toy in toys: play_with(toy) The for loop goes through each toy ( toy ) in the toys list it tells our magical robot arm to play_with() each toy It will keep playing with each toy until it has gone ...