我在python 3中创建了一个程序,询问您的姓名,年龄和密码。我收到语法错误,我不知道为什么。 这是我的代码:
import time
needCheck = False
check = ("Just to check")
myName = ("Mason")
myAge = (12)
thePassword = ("Potatos are gud")
print("...")
time.sleep(3)
print("Scanning")
time.sleep(3)
print("*HUMAN_LIFEFORM DETECTED*")
time.sleep(2)
print("Greetings inhabitant of planet Earth")
name = input("What is your name, Earthling?")
if name == myName:
print("Oh, it's you")
needCheck = True
else:
print("Salutations, " + name + "!")
if needCheck:
age = input(check + ", " "what is your age?")
if age == myAge:
print("Looking good so far...")
else:
print("You're not fooling me anymore...")
needCheck = False
else:
age = input("What is your age " + name + "?")
if age == myAge:
print("Hmmm...")
if needCheck:
pass = input(check + "again" + ", " + "what is the super secret password?")
if pass == thePassword:
print("I knew it was you!")
else:
print("You must be an imposter! Where is the real Mason?!")
else:
pass = input("What is the super secret password, " + name + "?")
if pass = thePassword:
print("How did you know that?!")
print("Self Destruct In:")
time.sleep(1)
print(3)
time.sleep(1)
print(2)
time.sleep(1)
print(1)
while True:
print(BOOM)
time.sleep(0.5)
IDLE说错误出现在这一行,等号:
pass = input(check + "again" + ", " + "what is the super secret password")
如果你知道它为什么语法无效,请回答。 谢谢!
答案 0 :(得分:2)
传递是一个保留字。尝试使用任何其他单词,它应该工作