mercredi 26 septembre 2018

I've set up a RNG and a continue button but it wont update the result after continuing

#Setting up RNG
loop = "y"
while loop == "y" or loop == "yes":
    from random import randint
    dice = (randint(1,10))
    dice2 = (randint(1,10))
    roll = (dice + dice2)
    win = 3
    loss = 2
    cash = 20
    if roll == 3 or roll == 7 or roll == 11 or roll == 17:
        cash += (win)
    else:
        cash -= (loss)
    #Starting game
    print("""Welcome to, Gambling for School!

    You have $20 and must earn as much money as possible

    If you roll a 3, 7, 11, or 17, you will win $3 but any other number 
takes $2

    You have a 20% of winning
""")
x = input("Press ENTER to start.")
#Results
if roll == 11 or roll == 8 or roll == 18:
    print("You rolled an " + str(roll) + "!")
else:
    print("You rolled a " + str(roll) + "!")
print("")
print("Cash - $" + str(cash))
loop = input("Continue? (Y/N) ").lower()

Had to change the indenting to show it as code

When it runs, I hit enter to start the game and it adds and subtracts correctly but when I select continue, it plays as if I never lost or gained any money. It is 1AM and idk if my brain died but I can't think of anything to fix it




Aucun commentaire:

Enregistrer un commentaire