day 11 - fixed a typo
This commit is contained in:
14
011/task.py
14
011/task.py
@ -3,7 +3,7 @@ import random
|
|||||||
def draw_cards(number):
|
def draw_cards(number):
|
||||||
cards = []
|
cards = []
|
||||||
for i in range(0, number):
|
for i in range(0, number):
|
||||||
card = random.randint(1,14)
|
card = random.randint(2,14)
|
||||||
if card >= 12:
|
if card >= 12:
|
||||||
card = 10
|
card = 10
|
||||||
if card == 11:
|
if card == 11:
|
||||||
@ -48,6 +48,12 @@ def compute_winner(player_cards, cpu_cards):
|
|||||||
else:
|
else:
|
||||||
print("You win")
|
print("You win")
|
||||||
|
|
||||||
|
def launch_new_game():
|
||||||
|
wanna_play = input('Do you want to play again? Type "y" or "n":')
|
||||||
|
|
||||||
|
if wanna_play == 'y':
|
||||||
|
play_blackjack([], [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def play_blackjack(player_cards, cpu_cards):
|
def play_blackjack(player_cards, cpu_cards):
|
||||||
@ -64,7 +70,7 @@ def play_blackjack(player_cards, cpu_cards):
|
|||||||
|
|
||||||
if player_score > 21:
|
if player_score > 21:
|
||||||
print("You went over 21 - You lose!")
|
print("You went over 21 - You lose!")
|
||||||
return
|
launch_new_game()
|
||||||
|
|
||||||
action = input('Type "y" to get another card, type "n" to pass:')
|
action = input('Type "y" to get another card, type "n" to pass:')
|
||||||
if action == 'y':
|
if action == 'y':
|
||||||
@ -72,10 +78,8 @@ def play_blackjack(player_cards, cpu_cards):
|
|||||||
else:
|
else:
|
||||||
dealer_game(cpu_cards)
|
dealer_game(cpu_cards)
|
||||||
compute_winner(player_cards, cpu_cards)
|
compute_winner(player_cards, cpu_cards)
|
||||||
wanna_play = input('Do you want to play again? Type "y" or "n":')
|
launch_new_game()
|
||||||
|
|
||||||
if wanna_play == 'y':
|
|
||||||
play_blackjack([], [])
|
|
||||||
|
|
||||||
wanna_play = input('Do you want to play a game of Blackjack? Type "y" or "n":')
|
wanna_play = input('Do you want to play a game of Blackjack? Type "y" or "n":')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user