편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2020.05.01

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


    from tkinter import *
    import random
    
    
    def rcp_game():
    
    
        com = random.choice(['가위', '바위', '보'])
        user =0
    
        if (user=='가위' and com=='보') or (user=='바위' and com =='가위') or(user=='보' and com=='바위') :
            lbl2.configure(text="사용자 승")
            lbl3 = Label(root, image = photo1)
            lbl3.place(x=100, y=30)
        elif (user=='가위' and com=='가위') or (user=='바위' and com =='바위') or(user=='보' and com=='보') :
            lbl2.configure(text="무승부")
            lbl3 = Label(root, image = photo2)
            lbl3.place(x=100, y=30)
        elif (user=='가위' and com=='바위') or (user=='바위' and com =='보') or(user=='보' and com=='가위') :
            lbl2.configure(text="컴퓨터 승")
            lbl3 = Label(root, image = photo3)
            lbl3.place(x=100, y=30)
        else:
            lbl2.configure(text="다시 입력")
            lbl3 = Label(root, image = photo2)
            lbl3.place(x=100, y=30)
    
    
    root = Tk()
    
    root.title("가위바위보")
    root.geometry("230x120")
    
    
    photo1 = PhotoImage(file = "smile.png")
    
    photo2 = PhotoImage(file = "try.png")
    
    photo3 = PhotoImage(file = "cry.png")
    
    
    
    
    lbl1 =Label(root, text="사용자")
    
    ent =Entry(root)
    
    lbl2 = Label(root, text ="승패결과")
    
    btn = Button(root, text = "확인", command= rcp_game)
    
    
    lbl1.place(x= 10, y=10)
    
    ent.place(x=50, y=10)
    
    btn.place(x=50, y=40)
    
    lbl2.place(x=50, y=80)
    
    
    root.mainloop()
    

    이렇게 짰는데 실행이 else부분만 돼요 (가위,바위,보 뭐를 넣든 '다시 입력' 글자만 떠요) 왜 if랑 elif 부분은 안 되는 걸까요?

  • 프로필 알 수 없는 사용자님의 편집
    날짜2020.04.30

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


    from tkinter import * import random

    def rcp_game():

    com = random.choice(['가위', '바위', '보'])
    user =0
    
    if (user=='가위' and com=='보') or (user=='바위' and com =='가위') or(user=='보' and com=='바위') :
        lbl2.configure(text="사용자 승")
        lbl3 = Label(root, image = photo1)
        lbl3.place(x=100, y=30)
    elif (user=='가위' and com=='가위') or (user=='바위' and com =='바위') or(user=='보' and com=='보') :
        lbl2.configure(text="무승부")
        lbl3 = Label(root, image = photo2)
        lbl3.place(x=100, y=30)
    elif (user=='가위' and com=='바위') or (user=='바위' and com =='보') or(user=='보' and com=='가위') :
        lbl2.configure(text="컴퓨터 승")
        lbl3 = Label(root, image = photo3)
        lbl3.place(x=100, y=30)
    else:
        lbl2.configure(text="다시 입력")
        lbl3 = Label(root, image = photo2)
        lbl3.place(x=100, y=30)
    

    root = Tk()

    root.title("가위바위보") root.geometry("230x120")

    photo1 = PhotoImage(file = "smile.png")

    photo2 = PhotoImage(file = "try.png")

    photo3 = PhotoImage(file = "cry.png")

    lbl1 =Label(root, text="사용자")

    ent =Entry(root)

    lbl2 = Label(root, text ="승패결과")

    btn = Button(root, text = "확인", command= rcp_game)

    lbl1.place(x= 10, y=10)

    ent.place(x=50, y=10)

    btn.place(x=50, y=40)

    lbl2.place(x=50, y=80)

    root.mainloop()

    이렇게 짰는데 실행이 else부분만 돼요 (가위,바위,보 뭐를 넣든 '다시 입력' 글자만 떠요ㅜ)ㅜ 왜 if랑 elif 부분은 안 되는 걸까요..?