【发布时间】:2017-06-05 20:01:57
【问题描述】:
代码:
#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: ")
问题:
当我运行程序并输入“错误”的东西时,它总是运行相同的功能,我不知道为什么!
【问题讨论】:
-
这不是C++,你不需要用
;终止行 -
不要限制密码长度,你会散列密码所以你不需要限制这个。
-
stuart ---我必须这样做,这是为了课程作业。
标签: python if-statement printing while-loop passwords