QUESTION IMAGE
Question
complete the code to check the length of a password. when done, valid should be true if the password is between eight and 20 characters long. valid will be false if it is not. valid = true password = input(\password? \) lengthpassword = (password) if lengthpassword 20: valid = false elif lengthpassword 8: valid = false
Step1: Get password length
In Python, the len function is used to get the length of a string. So the first blank should be len.
Step2: Check upper - length limit
We need to check if the length is greater than 20 to set valid to False. So the operator in the second blank should be >.
Step3: Check lower - length limit
We need to check if the length is less than 8 to set valid to False. So the operator in the third blank should be <.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
lengthPassword = len(password)
if lengthPassword > 20:
valid = False
elif lengthPassword < 8:
valid = False