Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Cyber Battle Game
Game elements
Main Game Loop
10. Step 6c – displaying a verdict
Final game

Instruction

Great! Now it's time to display the verdict!

Keeping your code inside functions is a programming best practice. That's why we should now create a main() loop that takes care of the game's primary logic.

Exercise

Display a verdict. Instead of always printing '*** Draw! ***', do the following operations inside the main() function:

  1. If robot A has more than 0 lives and robot B has 0 lives, print
    *** Robot A won! ***
  2. If robot B has more than 0 lives and robot A has 0 lives, print
    *** Robot B won! ***
  3. Otherwise, print
    *** Draw! ***