import time
def Scenario2():
film_comedy = ['Anchorman','The Hangover','Ted']
film_horror = ['The Exorcist','The Shining','Scream']
film_action = ['Die Hard','The Matrix','Batman']
film_animation = ['Toy Story','The Incredibles','The Lion King']
print("Hello, welcome to the online streaming service")
username = len(input("Please Enter a username between 4 and 12 characters: "))
while username < 4 or username > 12:
print("That username is not within the boundaries")
username = len(input("Please Enter a username between 4 and 12 characters: "))
password = input("Now enter a password: ")
password1 = input("Please re-enter the password: ")
if password1 == password:
print("Congratualtions on your new account")
while password1 != password:
print("They don't match")
password = input("Now enter a password: ")
password1 = input("Please re-enter the password: ")
if password1 == password:
print("Congratualations on your new account")
usernameinput = input("Please Enter your username: ")
if usernameinput == username:
print("Great job")
while usernameinput != username:
print("That is the incorrect Username")
usernameinput = input("Please Enter your username: ")
if usernameinput == username:
print("Great job")
Scenario2()
每当我输入用户名时,输入与用户名相同的内容。它并没有说做得好,而是说它是错误的。
我可以得到一些帮助吗?
最佳答案
while usernameinput != username:
print("That is the incorrect Username")
usernameinput = input("Please Enter your username: ")
if usernameinput == username:
print("Great job")
这不起作用,因为您在此 while
之前分配了 username = len(input("Please Enter a username between 4 to 12characters: "))
循环,重命名变量以使其正常工作。
关于python - 当我输入用户名时,未显示 "good job",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46042585/