I’m trying to write a program for the dice in a game of risk. It runs but the 
problem is that if any of the offensive dice is bigger than only one of the 
defensive dice, the program shows the offense as the winner, even when the 
defense should win. Can you help me out with this?

here’s the code:

# To be used during risk in the abesense of dice

import random

o_die1 = random.randint(1, 6)
o_die2 = random.randint(1, 6)
o_die3 = random.randint(1, 6)

d_die1 = random.randint(1, 6)
d_die2 = random.randint(1, 6)

print "the offense has rolled a %s, %s and a %s" % (o_die1, o_die2, o_die3)

print "The defense has rolled a %s and a %s" % (d_die1, d_die2)

def winner():
    if o_die1 > d_die1 or d_die2:
        print "The offense has won"
    elif o_die2 > d_die1 or d_die2:
        print "The offense has won"
    elif o_die3 > d_die1 or d_die2:
        print "The offense has won"
    else:
        print "The defense has won"
           
winner()

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to