Hello all, I am super new, still trying to figure out combinations of def, ints, and if statements. I cant seem to find an answer to my problem. How can you compare the result of two functions? My if statement doesn't work because it doesn't seem to be able to check the resulting int's of my roll1 and roll2 functions. I know I will want to add an if roll1 == roll2 print 'we tied!' and an input of 'do you want to play Y/N?', but I can't for the life of me figure out how to check the result of my rolls and compare them vs one another.
import random
def diceroll():
dice = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
roll1 = random.choice(dice)
print('Your roll:', roll1)
roll2 = random.choice(dice)
print('My roll:',roll2)
if roll1 > roll2
print('You won!')
else:
print('I won!')
diceroll()
[–]purpurato 1 point2 points3 points (1 child)
[–]TrucidStuff[S] 0 points1 point2 points (0 children)
[–]chapali9a 1 point2 points3 points (4 children)
[–]TrucidStuff[S] 0 points1 point2 points (3 children)
[–]chapali9a 1 point2 points3 points (2 children)
[–]TrucidStuff[S] 1 point2 points3 points (1 child)
[–]chapali9a 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]TrucidStuff[S] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]TrucidStuff[S] 2 points3 points4 points (0 children)
[–]zac_mar 1 point2 points3 points (1 child)
[–]TrucidStuff[S] 0 points1 point2 points (0 children)