← Back to the workshop

Dice Battle (in Python)

✅ It works!

Python

See the code 💻

My first program that other people actually played.

The idea

You roll a dice. The computer rolls a dice. Highest number wins the round. First to 3 rounds wins the game.

The code bit I’m proud of

I learned about random and about while loops — the loop keeps the game going until somebody wins, so I don’t have to copy-paste the same code 5 times.

import random

while me < 3 and robot < 3:
    print("Rolling!")

What’s next

I want to add a dragon that cheats sometimes.