1

Using random module and creating functions to roll dice in a craps simulation, every time I run the code it end's up just printing the first win statement. Any suggestions?


import random

print('Craps: A Popular Dice Game')
roll = ''
def rolldie(roll):

    print()
    enter = input('Press <Enter> to roll the dice.')

    if enter == "":
        point = "first"
        die1 = random.randint(1,6)
        die2 = random.randint(1,6)
        roll = die1 + die2
        print(die1, die2)
        print(f'\nYou rolled a {roll} on your {point} roll.')
        point = "second"
        return roll

def main():

    rolldie(roll)

    if roll == 7 or 11:
        print('\nYou win! 1')
    elif roll == 2 or 3 or 12:
        print('\nYou lose! 2')
    else:
        print("\nThat's your point. Roll it again before you roll a 7 and lose!")

        rolldie(roll)

        if roll == 7 or 2 or 3 or 12:
            print('\nYou lose! 3')
        else:
            print('\nYou win! 4')

main()
papatri
  • 11
  • 2
  • `if roll == 7 or 11` doesn't do what you think it does. Try `if roll == 7 or roll == 11` to see what I mean (then you will need to fix the other similar issues in your code. – benvc Apr 05 '19 at 16:02
  • @benvc Thanks for the help, I can't believe I overlooked that! – papatri Apr 06 '19 at 01:48

0 Answers0