我目前正在尝试编程一块石头,布,剪刀!Python游戏。我面临的问题是,当我赢了,比分似乎没有改变,当我赢了,电脑仍然说我输了。顺便说一句,这都是我自己的编程,我才刚上6年级。这是我的代码:
print("Welcome to my Rock, Paper, Scissors! game. Its quite simple. 'R' = Rock, 'P' = Paper and 'S' = Scissors. All of your inputs must begin with a capital letter. Good luck! Here we go!")
import random
Computer_RPS = ["Rock", "Paper", "Scissors"]
def RPS():
Cpoints = 0
Upoints = 0
one = 1
User_choice1 = input("Rock, Paper, Scissors!...")
Computer_choice1 = (random.choice(Computer_RPS))
"""
while (User_choice1 != "Rock" or "Paper" or "Scissors" or "R" or "P" or "S"):
User_choice1 = input("That value is not valid. Lets try again; Rock, Paper, Scissors!...")
"""
if User_choice1 == Computer_choice1:
print("Draw. Getting tense!...")
print("I chose:" + (Computer_choice1))
print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
elif Computer_choice1 == "Rock" and User_choice1 == "S" or "Scissors":
(Cpoints) + (one)
print("Good try. Better luck next time!")
print("I chose:" + (Computer_choice1))
print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
elif Computer_choice1 == "Paper" and User_choice1 == "R" or "Rock":
(Cpoints) + (one)
print("Unlucky. But that means 1 point to me!")
print("I chose:" + (Computer_choice1))
print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
elif Computer_choice1 == "Scissors" and User_choice1 == "P" or "Paper":
(Cpoints) + (one)
print("Unlucky. But that means 1 point to me!")
print("I chose:" + (Computer_choice1))
print("The score stands at: " + str(Cpoints) + " to me and " + str(Upoints) + " to you.")
else:
print("Well Done! You beat me. :'-( Never mind. One point to you.")
Upoints += 1
RPS()
RPS()
RPS()
下面是我的代码及其输出的屏幕截图: My code and its output.
任何帮助我都将不胜感激。谢谢你抽出时间来读我的问题。在
运算符优先级有问题。考虑一下这个:
相关问题 更多 >
编程相关推荐