Removed useless variable
This commit is contained in:
12
011/task.py
12
011/task.py
@ -2,7 +2,7 @@ import random
|
||||
|
||||
def draw_cards(number):
|
||||
cards = []
|
||||
for i in range(0, number):
|
||||
for _i in range(0, number):
|
||||
card = random.randint(2,14)
|
||||
if card >= 12:
|
||||
card = 10
|
||||
@ -13,7 +13,7 @@ def draw_cards(number):
|
||||
|
||||
def count_score(cards):
|
||||
score = sum(filter(lambda card: isinstance(card, int), cards))
|
||||
for ace in filter(lambda card: isinstance(card, str), cards):
|
||||
for _ in filter(lambda card: isinstance(card, str), cards):
|
||||
if score + 11 > 21:
|
||||
score += 1
|
||||
else:
|
||||
@ -36,8 +36,8 @@ def compute_winner(player_cards, cpu_cards):
|
||||
player_score = count_score(player_cards)
|
||||
cpu_score = count_score(cpu_cards)
|
||||
|
||||
print(f'Your cards: {player_cards} - Score: {player_score}')
|
||||
print(f'Computer cards: {cpu_cards} - Score: {cpu_score}')
|
||||
display_players_cards(player_cards, player_score)
|
||||
display_players_cards(cpu_cards, cpu_score)
|
||||
|
||||
if cpu_score > 21:
|
||||
print("Dealer went over 21 - You win!")
|
||||
@ -54,8 +54,6 @@ def launch_new_game():
|
||||
if wanna_play == 'y':
|
||||
play_blackjack([], [])
|
||||
|
||||
|
||||
|
||||
def play_blackjack(player_cards, cpu_cards):
|
||||
if player_cards == []:
|
||||
player_cards = draw_cards(2)
|
||||
@ -80,8 +78,6 @@ def play_blackjack(player_cards, cpu_cards):
|
||||
compute_winner(player_cards, cpu_cards)
|
||||
launch_new_game()
|
||||
|
||||
|
||||
wanna_play = input('Do you want to play a game of Blackjack? Type "y" or "n":')
|
||||
|
||||
if wanna_play == 'y':
|
||||
play_blackjack([], [])
|
||||
|
||||
Reference in New Issue
Block a user