Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

complete the code to check the length of a password. when done, valid s…

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

Explanation:

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 <.

Answer:

lengthPassword = len(password)
if lengthPassword > 20:
valid = False
elif lengthPassword < 8:
valid = False