ARTICLE AD BOX
It's been a long time since I delved into python and as an exercise I tried making a simple roulette game. Using the code below I hoped that whenever the user wins/looses, their chip amount would update accordingly and the game would loop until it hits zero. However the chips just reset to 500 each time a loop is completed (an error I expected).
A second problem is that the user could just input more amount of chips than they have, I'm trying to figure out a way to make a user redo the input if they do this but am currently stuck on this. Any help would be appreciated.
import numpy as np chips = 500 print(f"your amount of chips = {chips}") while (chips > 0): bet = int(input("Place your bet: ")) if bet <= chips: chips = 500 - bet else: print("Insufficient bet") guess = str(input("Odd or Even: ")).lower() number = int(np.random.randint(1,36)) print(number) if number % 2 == 0 and guess == "even": print("Jackpot, it's even!") chips = chips + 2*bet elif number % 2 != 0 and guess == "odd": print("Jackpot, it's odd!") chips = chips + 2*bet else: print("Better luck next time") print(chips) else: print("You're out of chips!")Explore related questions
See similar questions with these tags.
