Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import shuffle
- player_score = barmen_score = 0
- money = 50
- bet = 0
- deck = [2, 3, 4, 6, 7, 8, 9, 10, 11] * 4
- shuffle(deck)
- while True:
- while not bet:
- bet = int(input('Your money - {0}\nSet your bet:\n'.format(money)))
- if bet <= money and bet <= money:
- money -= bet
- else:
- bet = 0
- print("You don't enough money")
- answer = input('Do you want to take a card? (y/n)\n') if player_score < 21 else 'n'
- if answer == 'y':
- card = deck.pop()
- player_score += card
- print('You got {0}. Your score - {1}'.format(card, player_score))
- elif answer == 'n':
- while barmen_score < 15:
- barmen_score += deck.pop()
- win = (player_score > barmen_score or barmen_score > 21) and player_score <= 21
- print('Your count - {0}\nBarmen count - {1}'.format(player_score, barmen_score))
- print('You {0}'.format('win!' if win else 'loose!'))
- end = input('Repeat? (y/n)\n')
- if end == 'y':
- money += bet*2 if win else 0
- if money == 0:
- print("You don't have enough money")
- break
- bet = 0
- player_score = barmen_score = 0
- elif end == 'n':
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement