Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 44 additions & 39 deletions RouletteSingleNumberGame.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
import random
import time

balance = 100
spins = 0
guess = 0


while guess != "exit":
number = random.randint(0,36)
guess = input("Welcome to roulette, what number would you like to place a bet on? Type 'exit' to leave ")
if guess == "exit":
print "Thanks for playing, your final balance is",balance,"and have stayed for",spins,"plays"
break
if guess > 36 or guess < 0:
print "That number is not on the table"
else:
print 'You have',balance,"remaining"
bet = input("How much would you like to bet? ")
if bet > balance:
print "You don't have enough money for that bet"




def play():
balance = 100
spins = 0
guess = 0


if 0 < bet <= balance and 0 <= guess <= 36:
print "You have bet",bet
guess = int(guess)
spins += 1
print '**Spinning**'
time.sleep(3)
if guess == number:
print "Congratulations, it landed on",number,", you win!!"
balance += bet*36
print "Your new balance is",balance

while guess != "exit":
number = random.randint(0, 36)
try:
guess = int(input("Welcome to roulette, what number would you like to place a bet on? Type 'exit' to leave "))
except ValueError:
continue
if guess == "exit":
print("Thanks for playing, your final balance is", balance, "and have stayed for", spins, "plays")
break
if guess > 36 or guess < 0:
print("That number is not on the table")
else:
print "Sorry, it landed on",number,", better luck next time"
balance += -bet
if balance > 0:
print "Your new balance is",balance
print('You have', balance, "remaining")
try:
bet = int(input("How much would you like to bet? "))
except ValueError:
bet = 0
if bet > balance:
print("You don't have enough money for that bet")

if 0 < bet <= balance and 0 <= guess <= 36:
print("You have bet", bet)
guess = int(guess)
spins += 1
print('**Spinning**')
time.sleep(3)
if guess == number:
print("Congratulations, it landed on", number, ", you win!!")
balance += bet * 36
print("Your new balance is", balance)

else:
print "Sorry, you are out of cash"
break
print("Sorry, it landed on", number, ", better luck next time")
balance += -bet
if balance > 0:
print("Your new balance is", balance)
else:
print("Sorry, you are out of cash")
break

if __name__ == "__main__":
play()