代码:
#Welcome the user to the application.
print("Hello, please enter a password with a minimum of six characters and a max of twelve.");
#Set a variable called MinPass and set a value of 6.
MinPass = 6;
#Set a variable called MaxPass and set a value of 12.
MaxPass = 12;
#Set variable EnteredPass and wait for user input
EnteredPass = input("Password: ");
while len(EnteredPass) < MinPass:
print("Your password is too short, please enter a longer password and try again")
EnteredPass = input("Password: ");
while len(EnteredPass) > MaxPass:
print("Your password is too long, please shorten it and try again!");
EnteredPass = input("Password: ");
else:
print("Accepted!")
while EnteredPass.isdigit:
print("Needs letters");
EnteredPass = input("Password: ");
if EnteredPass.isalpha:
print("Needs numbers")
EnteredPass = input("Password: ")
问题是:
当我运行程序,输入错误的东西,它总是运行相同的功能,我不知道为什么
你需要调用你的函数
而不是
后者只是隐式地将函数对象转换为
bool
,这将始终导致True
相关问题 更多 >
编程相关推荐