Reputation: 17
dice1 = random.randint(1, 6)
if (dice1 % 2) == 0:
print("This number is even. Adding 10 to score.")
player1score = player1score + 10
else:
print("This number is odd. Subtracting 5 from score.")
player1score = player1score - 5
if player1score < 0:
print("Your score is too low. Reseting it to 0.")
player1score = 0
dice2 = random.randint(1, 6)
if (dice2 % 2) == 0:
print("This number is even. Adding 10 to score.")
player1score = player1score + 10
else:
print("This number is odd. Subtracting 5 from score.")
player1score = player1score + 10
if player1score < 0:
print("Score too low, reseting to 0.")
player1score = 0
print(player1score)
I ran this code and it came out as odd twice. The reset print worked but it never reset the variable back to 0 and at the end it showed the variable as 10 instead of 0 or a negative number. I'm confused
Help would be appreciated
Upvotes: 0
Views: 51
Reputation: 124
It looks like you are not doing what your comment says, on dice2 else-statement you are giving 10 points even though you say that you will subtract 5. Typo in comment or in code?
Upvotes: 2