파이썬으로 가위바위보 게임

조회수 3669회
import random

com = random.choice(['가위', '바위', '보'])
user = 0


user = input("가위, 바위, 보 중 하나를 입력 (끝내려면 '종료' ):")

com = random.choice(["가위", "바위", "보"])

if user == '종료':
    print('프로그램 종료\n')

elif (user=='가위' and com=='보') or (user=='바위' and com =='가위') or(user=='보' and com=='바위') :
    print('사용자 : '+user+', 컴퓨터 : '+com+', 사용자 승\n')
elif (user=='가위' and com=='가위') or (user=='바위' and com =='바위') or(user=='보' and com=='보') :
    print('사용자 : '+user+', 컴퓨터 : '+com+', 무승부\n')
elif (user=='가위' and com=='바위') or (user=='바위' and com =='보') or(user=='보' and com=='가위') :
    print('사용자 : '+user+', 컴퓨터 : '+com+', 컴퓨터 승\n')
else:
    print('다시 입력해 주세요.\n')

얘도 제대로 실행되고

동전 던지기 게임

import turtle

import random

t = turtle.Turtle()
s = turtle.Screen()

img1 = "front.gif"
img2 = "back.gif"

s.addshape(img1)
s.addshape(img2)

value = random.choice(["앞", "뒤"])

if value == "앞" :
    t.shape(img1)
else :
    t.shape(img2)

둘 다 제대로 실행 되는데

t=turtle.Turtle()

s=turtle.Screen()

img1 = "smile.png"

img2 = "try.png"

s.addshape(img1)

s.addshape(img2)

com = random.choice(['가위', '바위', '보'])

user = 0


user = input("가위, 바위, 보 중 하나를 입력 (끝내려면 '종료' ):")

com = random.choice(["가위", "바위", "보"])

if user == '종료':
    print('프로그램 종료\n')

elif (user=='가위' and com=='보') or (user=='바위' and com =='가위') or(user=='보' and com=='바위') :

     print('사용자 : '+user+', 컴퓨터 : '+com+', 사용자 승\n')
    t.shape(img1)
elif (user=='가위' and com=='가위') or (user=='바위' and com =='바위') or(user=='보' and com=='보') :

    print('사용자 : '+user+', 컴퓨터 : '+com+', 무승부\n')
    t.shape(img2)


elif (user=='가위' and com=='바위') or (user=='바위' and com =='보') or(user=='보' and com=='가위') :

     print('사용자 : '+user+', 컴퓨터 : '+com+', 컴퓨터 승\n')
     t.shape(img2)
else:
    print('다시 입력해 주세요.\n')

얘는 왜 안 될까요?

  • 안된다는게 어떻게 안된다는건지 명확하게 써 주셔야죠.. HIAOAIH 2020.5.10 19:55

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)