为什么我的代码没有退出无限循环? (python)
Why isn't my code exiting the infinite loop? (python)
我对 Python 很陌生。我正在创建一个程序,开始从事我认为具有革命性的重大工作。然而,当我保存我的代码并对其进行测试时,它仍然处于我创建的无限循环中,即使在我输入了一些与条件不匹配的内容之后也是如此!我能得到一些帮助吗?
代码:
*...snip...* print("You may now choose a password. Your password must: \n"
+ "-be at least 8 characters \n"
+ "-NOT be 'password' \n"
+ "-NOT be an ordered list of numbers \n")
print("What is your password?")
password = input()
if password == "password" or "Password" or "PASSWORD" or "12345678":
while password == "password" or "Password" or "PASSWORD" or "12345678":
print("That password is too weak. Choose another password.")
password = input()
else: *...snip...*
你必须写
if password == "password" or password == "Password" or password == "PASSWORD" or password == "12345678":
您的 if 会像这样评估您的语句:如果密码等于字符串“password”或者字符串“Password”是否不同于 null 等等。
我对 Python 很陌生。我正在创建一个程序,开始从事我认为具有革命性的重大工作。然而,当我保存我的代码并对其进行测试时,它仍然处于我创建的无限循环中,即使在我输入了一些与条件不匹配的内容之后也是如此!我能得到一些帮助吗?
代码:
*...snip...* print("You may now choose a password. Your password must: \n"
+ "-be at least 8 characters \n"
+ "-NOT be 'password' \n"
+ "-NOT be an ordered list of numbers \n")
print("What is your password?")
password = input()
if password == "password" or "Password" or "PASSWORD" or "12345678":
while password == "password" or "Password" or "PASSWORD" or "12345678":
print("That password is too weak. Choose another password.")
password = input()
else: *...snip...*
你必须写
if password == "password" or password == "Password" or password == "PASSWORD" or password == "12345678":
您的 if 会像这样评估您的语句:如果密码等于字符串“password”或者字符串“Password”是否不同于 null 等等。