I am trying to create python code that checks whether a password is:
Is at least 6 characters long. Contains both letters and numbers. Isn't letters only. Isn't numbers only.
Doesn't use any: Imported libraries. Loop Structures. User defined inputs.
Here is the code:
MIN_PASSWORD_LENGTH = 6
MAX_PASSWORD_LENGTH = 10
password = input('Enter your Password:\n')
password_length = len(password)
#Do I need the two lines below?
#if (len(password) < 6 or len(password) > 10) :
# print ("Password is Weak - Doesn't Meet Length Requirements")
#below code checks input for alphabetical characters
if password.isalpha :
print ("Password is Weak - Only Contains Letters")
#below code checks input for numerical characters
elif password.isnumeric :
print ("Password is Weak - Only Contains Numbers")
#cannot get it to recognise numbers inputed into password field, mistakes numbers for letters
#below code checks input for both alphabetical and numerical characters
elif password.isalnum :
print ("Password is Strong")
I need help with this (am I missing something?), any help would be appreciated.
This is a basic code for the check and re or regular expression library is pre-installed it checks for all the condition and returns True or False based on it.