SHARE
TWEET

Jack

a guest Jan 19th, 2020 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from random import shuffle
  2. player_score = barmen_score = 0
  3. money = 50
  4. bet = 0
  5. deck = [2, 3, 4, 6, 7, 8, 9, 10, 11] * 4
  6. shuffle(deck)
  7.  
  8. while True:
  9.     while not bet:
  10.         bet = int(input('Your money - {0}\nSet your bet:\n'.format(money)))
  11.         if bet <= money and bet <= money:
  12.             money -= bet
  13.         else:
  14.             bet = 0
  15.             print("You don't enough money")
  16.  
  17.     answer = input('Do you want to take a card? (y/n)\n') if player_score < 21 else 'n'
  18.     if answer == 'y':
  19.         card = deck.pop()
  20.         player_score += card
  21.         print('You got {0}. Your score - {1}'.format(card, player_score))
  22.     elif answer == 'n':
  23.         while barmen_score < 15:
  24.             barmen_score += deck.pop()
  25.  
  26.         win = (player_score > barmen_score or barmen_score > 21) and player_score <= 21
  27.         print('Your count - {0}\nBarmen count - {1}'.format(player_score, barmen_score))
  28.         print('You {0}'.format('win!' if win else 'loose!'))
  29.  
  30.         end = input('Repeat? (y/n)\n')
  31.         if end == 'y':
  32.             money += bet*2 if win else 0
  33.             if money == 0:
  34.                 print("You don't have enough money")
  35.                 break
  36.             bet = 0
  37.             player_score = barmen_score = 0
  38.         elif end == 'n':
  39.             break
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top