CODE

컴퓨터 프로그래밍 동아리

 깃허브: https://github.com/JBNU-HS-CODE/ 

전북사대 컴퓨터 프로그래밍 동아리

가위바위보

이름 이태수 등록일 25.12.24 조회수 3
import random

def rock_paper_scissors():
    print("=== 가위바위보 게임 ===")
    choices = ["가위""바위""보"]

    while True:
        user_choice = input("가위, 바위, 보 중 선택: ")
        if user_choice not in choices:
            print("다시 선택해주세요.")
            continue

        computer_choice = random.choice(choices)
        print(f"컴퓨터: {computer_choice}")

        if user_choice == computer_choice:
            print("무승부")
        elif (user_choice == "가위" and computer_choice == "보"or \
             (user_choice == "바위" and computer_choice == "가위"or \
             (user_choice == "보" and computer_choice == "바위"):
            print("?? WIN!")
        else:
            print("?? LOSE...")

        again = input("다시 플레이이 (y/n): ")
        if again.lower() != 'y':
            break

rock_paper_scissors()

이전글 테스트
다음글 숫자 맞추기