import random # 調用隨機數模塊 pc = random.randint(1,3) # 產生1-3的隨機數 print("來玩個猜拳遊戲吧!") a = '石頭' b = '剪刀' c = '布' user = input('請輸入(石頭,剪刀,布):') if user == '石頭': print("你出了石頭") elif user == '剪刀': print("你出了剪刀") else: print("你出了布") if pc == 1: print('電腦出了石頭') elif pc == 2 : print('電腦出了剪刀') else: print('電腦出了布') if user == '石頭' and pc == 2 or user =='剪刀' and pc == 3 or pc == 3 or user == '布' and pc == 1: print("你贏了") elif user == '石頭' and pc ==3 or user == '剪刀' and pc == 1 or user == '布' and pc == 2: print('你輸了') else: print('平局')