A video game repeats the action until all the players’ lives have gone, or the end of the game has been reached. So far, we have only written programs that run through a sequence of commands and then terminate. With the use of certain Python keywords, we can get the computer to repeat a block of code when required, either using conditions or for a set number of times.
© Sloan Kelly 2019Sloan KellyPython, PyGame, and Raspberry Pi Game Developmenthttps://doi.org/10.1007/978-1-4842-4533-0_6
6. Making the Raspberry Pi Repeat Itself
Niagara Falls, ON, Canada
The ‘for loop’ in Python takes a list, and for each item in the list it performs a series of action. These actions are contained within the block of code that appears ...