Step 4: Best of Three ๐
One round, one winner, program over. A real showdown goes to best of three โ first player to 2 wins takes the trophy. ๐
That means two things your game doesn't have yet: scores that remember what happened, and a loop that keeps playing until somebody reaches 2:
points = 0
while points < 3:
points = points + 1
print(f"Points so far: {points}")
The loop condition is the whole game: while player_score < 2 and computer_score < 2: keeps going only while neither of you has 2 wins.
One thing that's easy to miss: the computer's random.choice() has to
move inside the loop. Outside it, the computer picks once and throws the
exact same move all match. ๐ฟ
Your mission
- Before the loop, make
player_score = 0andcomputer_score = 0 - Open with a banner title screen (
"=" * 30style) while player_score < 2 and computer_score < 2:โ inside it, run a full round: computer picks, player types, winner decided- Add 1 to the winner's score (a tie scores nothing!) and print the score after every round
- After the loop, announce the champion between banner lines ๐
Your code
Press โถ Run to see what your code does!