") if sum_card(user_card) > 21: print("패배하였습니다.") game_over = True elif sum_card(user_card) == 21: print("승리하였습니다!") game_over = True if draw == "y" : user_card_draw"> ") if sum_card(user_card) > 21: print("패배하였습니다.") game_over = True elif sum_card(user_card) == 21: print("승리하였습니다!") game_over = True if draw == "y" : user_card_draw"> ") if sum_card(user_card) > 21: print("패배하였습니다.") game_over = True elif sum_card(user_card) == 21: print("승리하였습니다!") game_over = True if draw == "y" : user_card_draw">
import random
from art import logo
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]

user_card = []
dealer_card = []

# 유저 카드 뽑기
def user_card_draw(number_of_times) :
    for n in range(number_of_times) :
        draw = random.choice(cards)
        user_card.append(draw)

# 딜러 카드 뽑기
def delaer_card_draw(number_of_times) :
    for n in range(number_of_times) :
        draw = random.choice(cards)
        dealer_card.append(draw)

# 카드 합계 계산
def sum_card(cards) :
    sum = 0
    for n in range(len(cards)) :
        sum += cards[n]
    return sum

# 게임 시작
# 카드 드로우
user_card_draw(2)
delaer_card_draw(2)

# 카드 공개
print(logo)
print(f"유저 카드 : {user_card}")
print(f"딜러 카드 : {dealer_card[0]}")

game_over = False
while not game_over :

    draw = input("카드를 뽑으시겠습니까? y or n \\n > ")

    if sum_card(user_card) > 21:
        print("패배하였습니다.")
        game_over = True
    elif sum_card(user_card) == 21:
        print("승리하였습니다!")
        game_over = True

    if draw == "y" :
        user_card_draw(1)
        print(f"유저 카드 : {user_card}")

        if sum_card(user_card) > 21 :
            print("패배하였습니다.")
            game_over = True
        elif sum_card(user_card) == 21 :
            print("승리하였습니다!")
            game_over = True
        else :
            pass

    elif draw == "n" :
        # 에이스 확인
        if 11 in user_card :
            if sum(user_card) < 10 :
                pass
            else :
                user_card[user_card.index(11)] = 1

        if sum_card(dealer_card) < 15 :
            delaer_card_draw(1)

        print(f"유저 카드 : {user_card}")
        print(f"딜러 카드 : {dealer_card}")

        if dealer_card == user_card :
            print("무승부입니다.")
        elif user_card == 21 :
            print("블랙잭입니다. 승리하였습니다!")
        elif user_card > dealer_card :
            print("승리하였습니다!")
        else :
            print("패배했어요!")