Page 59 -
P. 59
indent or else
Pool Puzzle Solution
Your task was to take the Python code
fragments from the pool and place
them into the blank lines in the
game. You could not use the same
code fragment more than once,
and you didn’t need to use all
the code fragments. Your goal
was to complete the guessing game
program.
Hint: Don’t forget to indent.
print("Welcome!")
Did you remember
g = input("Guess the number: ")
guess = int(g) to indent your
if guess == 5: code deep enough?
print("You win!")
else:
All of this code is if guess > 5:
indented under the
print("Too high")
else part of the
else:
original if part.
print("Too low")
print("Game over!")
This piece of code
from the first version
of this program is no
longer needed.
print("You lose!")
else:
if guess <= 5:
24 Chapter 1