O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Checking for a Win

Before we create the main game loop, we need one final function. Each time the player knocks out a brick, the score variable is increased by 1. When the score variable is equal to the brickcount variable (which holds the number of bricks at the start of the game), the player has won. This short function checks and returns the value True if the player has won, and returns the value False if not. True and False don’t have quotation marks (or speech marks) around them because they’re not text strings. They’re special values you can use in Python.

def havetheywon():

if score==brickcount:

return True

else:

return False

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required