I just started python. Having some trouble using the if else statement in python. Im trying to create a program that checks the length of a password. If it matches the min length it should print your correct but when it doesnt print your not correct. When I run my code, it only prints out your correct even though the min length is not meet. Not sure if I have used the if else statement correctly, do I need to use 2 variables to make it work?
MIN_PASSWORD_LENGTH = 6 #The length of the password is determined by the variable MIN_PASSWORD_LENGTH.
#We have assigned the variable with the value of 6.
password = input('Enter your password: ')
password_length = len(password)
if MIN_PASSWORD_LENGTH >= 6:
print("Your password is correct!")
else:
print("Your not correct!")
print('Number of characters used in password: ', password_length,'and the min length expected is: ',MIN_PASSWORD_LENGTH)
Aucun commentaire:
Enregistrer un commentaire