Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Simple Craps Program

I’m making simple a Craps program, but it doesn’t run at all. There are no errors or anything, so I don’t know what is wrong with it. This is how it’s supposed to be played: A player rolls two six-sided dice and adds the numbers rolled together. On this first roll, a 7 or an 11 automatically wins, and a 2, 3, or 12 automatically loses, and play is over. If a 4, 5, 6, 8, 9, or 10 are rolled on this first roll, that number becomes the ‘point’. The player continues to roll the two dice again until one of two things happens: either they roll the ‘point’ again, in which case they win; or they roll a 7, in which case they lose.

def main():
    print("This program simulates a game of Craps.")
    print()
    need_instructions = input("Do you need the instructions? ")
    if need_instructions[0].lower() != "n":
        instructions()
    
    play = input("Do you want to play (Y/n) ")
    while (play[0].lower() != "n"):
        pause = input("Press <Enter> to roll the dice!")
        first_roll = diceRoll()
        print("You rolled " + str(first_roll) + " on your first roll.")
        
        if first_roll == 7 or first_roll == 11:
            print("You rolled a " + str(first_roll) + " on your first roll!")
            print("You WON!")
        elif first_roll == 2 or first_roll == 3 or first_roll == 12:
            print("You rolled a " + str(first_roll) + " on your first roll!")
            print("You LOST!")
        else:
            point = first_roll
            print("You rolled a " + str(point) + " on your first roll!")
            print("That's your Point. " + " Try to roll it again before you roll 7 and lose.")
            new_roll = diceRoll()
            
            while new_roll != point and new_roll != 7:
                roll2 = diceRoll()
                pause = input("Press <Enter> to roll the dice!")
                
                if roll2 == point:
                    print("You WON")
                else:
                    print("You LOST")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Call main or it won’t run at all.

like this:

main()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading