我试图做一个长的if
语句,它要求您注册或登录,但是当我进入登录部分时,出现了语法错误。有什么建议吗?你知道吗
registration = input("Do you have a registration")
if registration == "No":
name = input("Type your name: ")
surname = input("Type your surname: ")
userp1 = name[0]+ surname.capitalize()
print(userp1)
password = input("Enter your password\n")
userInput = input("Type your login details\n")
if userInput == userp1:
userInput = input("Password?\n")
if userInput== password:
print("Welocome")
change = input("Do you want to change your username?")
if change == "No":
print("You logged in as" , userp1)
else:
userp1 = input("What would your new username be?")
print("You logged in as",userp1)
else:
print("Login")
你的代码缩进不好。请注意,python对缩进非常敏感。
您也不需要指定所得到的错误。
因此,我冒昧地尝试编写一个与您的代码最大匹配的代码。
在这里:
您在最后一行连续编写两个
else
语句,这是无效语法。你可以把一个if语句放在另一个if语句中,你必须这样做。这是工作代码,但我不确定它是否是你试图使:相关问题 更多 >
编程相关推荐