I\'ve looked at the other post similar to my question, Password check- Python 3, except my question involves checking if the password contains both uppercase and lower case
You could use regular expression :
i.e. :
def Valid_mixed_password(password):
lower = re.compile(r'.*[a-z]+') # Compile to match lowercase
upper = re.compile(r'.*[A-Z]+') # Compile to match uppercase
if lower.match(password) and upper.match(password): # if the password contains both (lowercase and uppercase letters) then return True
return True
else: # Else, the password does not contains uppercase and lowercase letters then return False
return False
>>> print Valid_mixed_password("hello")
False
>>> print Valid_mixed_password("HELLO")
False
>>> print Valid_mixed_password("HellO")
True
>>> print Valid_mixed_password("heLLo")
True
Hope it helps.