Ask coding questions

← Back to all posts
Score board
TylerGibson99 (1)

In my game, if the number you have rolled is EVEN you gain +10 points.

If the number you have rolled is ODD, you gain -5 points. How do I make this score system?

Comments
hotnewtop
JBloves27 (1882)

Hello there,

So you can have many solutions, but some of them could be these:

import random
...
score=0
...
num = random.randint(1,5)
if num in [1,3,5]:
  score-=5
  print("You lost 5 points")
else:
  score+=10
  print("You won 10 points")

That could be one way, and another could be this:

import random
...
score=0
...
num = random.randint(1,5)
if num % 2 == 0:
  score+=10
  print("You got 10 points")
else:
  score-=5
  print("You lost 5 points")

I hope this helps!

TylerGibson99 (1)

If You're going to be looking at the game, to see what I mean.

username = TGibson123
password = TGibson123

then it should log you into the game