每当我运行它时,它会在 25% 到 50% 的时间里工作,我不知道为什么。以前我在使用 if 语句时遇到了麻烦,但这是一个我忘记的简单解决方法,但这让我感到困惑,因为它确实有效......有时。顺便说一句,这段代码是在 repl.it 上制作和运行的。编辑:我在最后添加了一个打印变量 rng 的部分,它说 typeError:'str' pbject is not callable
import random
rng=(random.randint(1,3))
player=input("rock, paper, or scissors ")
if player=="rock":
if rng==1:
print("paper covers your rock")
elif rng==2:
print=("both rock, tie")
elif rng==3:
print("your rock crushes scissors")
else:
print("error")
elif player=="paper":
if rng==1:
print("both paper, tie")
elif rng==2:
print=("your paper covers rock")
elif rng==3:
print("scisors cut your paper")
else:
print("error")
elif player=="scissors":
if rng==1:
print("your scissors cut paper")
elif rng==2:
print=("rock crushes your scissors")
elif rng==3:
print("both scissors, tie")
else:
print("error")
else:
print("error")
杨魅力
相关分类