Advertisement
oanap123

Python Project 2

Jul 7th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. def input_bet(bet, money):
  2.     #Ask for bet
  3.     bet_check = raw_input("Bet? (0 to quit, Enter to stay at $" + str(bet) + ") ")
  4.  
  5.     try:
  6.         int(bet_check)
  7.         #Quit game if player inputs 0
  8.         if bet_check == 0:
  9.             print("Player has quit")
  10.             quit()
  11.         #Check that bet is not negative
  12.         elif bet_check < 0:
  13.             try:
  14.                 bet_check >= 0
  15.             except ValueError:
  16.                 print("You cannot bet a negative amount")
  17.         #Check that bet is less than amount in account
  18.         else:
  19.             try:
  20.                 bet_check <= money
  21.             except ValueError:
  22.                 print("You cannot bet more than $" + money)
  23.  
  24.     except ValueError:
  25.         try:
  26.             float(bet_check)
  27.             try:
  28.                 bet_check % 1 == 0:
  29.             except TypeError:
  30.                 print("You must bet a whole number")
  31.  
  32.         except ValueError:
  33.             try:
  34.                 str(bet_check)
  35.  
  36.                 if bet_check == "":
  37.                     if bet < money:
  38.                         bet_check = bet
  39.                     elif bet > money:
  40.                         try:
  41.                             bet <= money
  42.                         except ValueError:
  43.                             print("You cannot bet more than $" + money)
  44.                 else:
  45.                     try:
  46.                         bet_check == ""
  47.                     except ValueError:
  48.                         print("You must type a number")
  49.     bet = bet_check
  50.  
  51.     return bet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement