Reputation: 11
while True:
password=input("Enter a password. Make sure it:\nContains at least 1 capital letter\nContains at least 6 letters\n")
time.sleep(0.35)
if len(password)>5 and password.islower=="False":
break
how do you make this stop. I want it to stop if it has one capital letter and is longer than 6 characters.
Upvotes: 1
Views: 86
Reputation: 8378
Because islower
is not a property but rather it is a function. Try this instead:
not password.islower()
In addition, as mentioned by @Dan, you compare the result of the islower()
function (a boolean) with a string "False"
. In Python a boolean result can be used directly as shown above without comparing it to a string "False"
(this is wrong) or to a boolean False
(which is weird and dangerous). islower()==False
would be True
if password contains upper case characters.
Upvotes: -1
Reputation: 77902
Here :
password.islower=="False"
First, you're not calling the method - you need to add parens - so you compare a method with a string. It will never be true...
Then, once you fix this:
password.islower() == "False"
you end up comparing a boolean with a string. It will never be true either, you want to compare with the boolean False
(no quotes):
password.islower() == False
As a last note, this is usually spelled:
not passsword.islower()
Upvotes: 5
Reputation: 5068
if len(password)>5 and not password.islower():
or
if len(password)>5 and password.islower() == False:
would work.
Upvotes: 1