435,240 views
38 votes
38 votes
Complete the code to check whether a string is between seven and 10 characters long. # Is the password at least six characters long? lengthPW = len(pw) if lengthPW : message = "Your password is too long." valid = False elif lengthPW : message = "Your password is too short." valid = False

User NemoXP
by
2.8k points

1 Answer

14 votes
14 votes

Answer:

lengthPW = len(pw)

if lengthPW > 10:

message = "Your password is too long."

valid = False

elif lengthPW < 7:

message = "Your password is too short."

valid = False

Step-by-step explanation:

You change the conditions to check if length is greater than 10 or less than 7, if it's greater than ten then it says your password is either too long or short depending on its length, then invalidates it.

User Cobry
by
3.2k points