1 year ago
#351926
Alex
Python, 2 dice, unable to progress (NEWBIE)
I'm trying to write a 'game' for 2 players: 2 dice, rolled until both dice show 6 (6 and 6 wins, 1 and 6 is a reroll of both dice etc.). I'm stuck as my code ends with any instance of rolling a 6. I can't figure out where the problem is.
Afterwards, second player rolls until two sixes show, I'll look into counting the rolls etc.
#double dice
import random
player1 = input("Player 1, press enter to roll the dice : ")
a = 0
b = 0
while (a and b) != 6:
player1 = input("Player 1, press enter to roll the dice : ")
a = random.randint(1,6)
b = random.randint(1,6)
print("You got " + str(a) + (" and ") + str(b))
I've even tried adding an extra check to see if it 'rolls' 2 sixes, but doesn't actually print it - no bueno.
if (a and b) == 6:
print("Awesome, you got it! " + str(a) + ("and") + str(b))
Googling stuff helps most of the time, but I'm still at the stage of struggling to understand what I'm looking at. Any help will be appreciated - preferably a description of the issue rather than fix in the code.
python
while-loop
dice
0 Answers
Your Answer