我对编程很陌生,我一直在研究摇滚、纸、剪刀的游戏。除了最后一部分(if
部分)之外,这一切都有效。
x = ("rock")
y = ("paper")
z = ("scissors")
print(x)
print(y)
print(z)
choices1 = (x, y, z)
choices2 = (x, y, z)
import random
print("player 1 chose...")
print(random.choice(choices1))
print("player 2 chose...")
print(random.choice(choices2))
if random.choice(choices1) = rock and random.choice(choices2) = scissors:
print("player 1 wins")
每当我尝试执行脚本时,它都会说:
File "<string>", line 14
if random.choice(choices1) = rock and random.choice(choices2) = scissors:
^
SyntaxError: invalid syntax