这是我的代码:
import random
import time
validInput = False
computer = (random.choice(["rock", "paper", "scissors"]))
batman = input("welcome to rock, paper, scissors would you like to play: yes or no?"
if batman == "yes":
choice = input("okay, these are the rules: I will say, rock, paper, scissors, shoot and then I will ask you what you picked and then tell you who won - are you ready to play: yes or no?")
if choice == "yes":
while validInput = False:
time.sleep(1)
print("rock")
time.sleep(1)
print("paper")
time.sleep(1)
print("scissors")
time.sleep(1)
print("shoot")
time.sleep(1)
what = input("what did you pick")
if what == "rock" and computer == "rock":
print("I picked rock too, I guess we drawed")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "rock" and computer == "paper":
print("I picked paper, so I guess I won better luck next time")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "rock" and computer == "scissors":
print("I picked scissors, I guess you win")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "paper" and computer == "paper":
print("I picked paper, so I guess we drawed")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "paper" and computer == "scissors":
print("I picked scissors, so I guess I won better luck next time")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "paper" and computer == "rock":
print("I picked rock, so I guess you won")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "scissors" and computer == "scissors":
print("I picked scissors, so I guess we drawed")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "scissors" and computer == "rock":
print("I picked rock, so I guess I won better luck next time")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
if what == "scissors" and computer == "paper":
print("I picked paper, so I guess you won")
fudge = input("do you want to play again: yes or no?)
if fudge == "yes":
print("restarting program")
continue
if fudge == "no":
print("okay, terminating program")
exit()
else:
print("invalid input, terminating program")
exit()
else:
chicken = input("invalid input, do you want to try again: yes or no?")
if chicken == "yes":
print("restarting now")
invalidInput = False
continue
if chicken == "no":
print("okay, terminating program")
invalidInput = True
exit()
else:
print("invalid input, terminating program")
invalidInput = True
exit()
if choice == "no":
print("okay terminating program")
invalidInput = True
exit()
else:
print("invalid input, terminating program")
exit()
if batman == "no"
print("okay, terminating program")
exit()
else:
print ("invalid input, terminating program")
exit()
我不知道为什么它不起作用它告诉我的是
SyntaxError:编译单个语句时找到多个语句。
有人可以帮助谢谢你。
哦我也在3.6.0上运行python
答案 0 :(得分:2)
在while循环中,您正在进行作业,而非比较,将=
更改为==
。
每次使用fudge()
时,结尾都会缺少引号。
最后,您if batman == "no"
应该是if batman == "no":
(注意两点)。