Code Monsters Academy
Home › Course contents › Level 7 - Both at Once
and / or

Level 7 - Both at Once

Chapter 2 · Monster League

and: true only when both conditions are true. or: true as long as at least one is true.

if hp > 20 and energy > 0:
    print("Ready to battle")
else:
    print("Take a rest")
GoalWrite an if: say "Ready to battle" only if HP is over 20 and energy is over 0; otherwise say "Take a rest".
Tipenergy is 0 right now, so if it's correct your partner should say "Take a rest".
Starting code
hp = 30
energy = 0
# If hp > 20 and energy > 0, say "Ready to battle"; otherwise say "Take a rest"
Practise this in the game
← Previous levelLevel 6 - Keep Going Until…Next level →Level 8 - Tag-Team Battle