Can anyone help me fix my issue with getting my code to pass onto the calculating_scores function without my coding wanting to loop back up every time I enter something into the another_card = input("Type 'y' if you'd like another card:\n")
def play():
global game_continue
user_cards = []
dealer_cards = []
for _ in range(2):
user_cards.append(deal_cards())
dealer_cards.append(deal_cards())
total_user = sum(user_cards)
print(f"You got the cards: {user_cards}, giving you a total of {total_user}\n")
print(f"The dealer got the card: {dealer_cards[0]}\n")
while game_continue:
another_card = input("Type 'y' if you'd like another card:\n")
if another_card == "yes" or another_card == "y":
user_cards.append(deal_cards())
new_user_total = sum(user_cards)
print(f"You have the cards, {user_cards}, giving you a total of: {new_user_total}")
dealer_total = dealer_cards[0] + dealer_cards[1]
print(f"The dealers second card was {dealer_cards[1]}, giving him a total of {dealer_total}")
calculating_scores(card_list=user_cards)
elif another_card == "no" or another_card == "n":
game_continue = False
dealer_total = dealer_cards[0] + dealer_cards[1]
print(f"The second dealers card was a {dealer_cards[1]} giving him a total of {dealer_total}")
calculating_scores(card_list=user_cards)
else:
print("Sorry this is an invalid option!")
# 10:16pm altering the arguments called after calculating_score to make the program properly function
def calculating_scores(card_list):
if sum(card_list) == 21:
return "Dealer won blackjack!"
if 11 in card_list and sum(card_list) > 21:
card_list.remove(11)
card_list.append(1)
return sum(card_list)