Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please make this Python code execute properly. User needs to create a password w

ID: 3924683 • Letter: P

Question

Please make this Python code execute properly. User needs to create a password with at least one digit, one uppercase, one lowercase, one symbol (see code), and the password has to be atleast 8 characters long. try1me is the example I used, but I couldn't get the program to execute properly. PLEASE INDENT PROPERLY.

def policy(password):
digit = 0
upper = 0
lower = 0
symbol = 0
length = 0
for i in range(0, len(password)):
if password[i].isdigit(): # checks each character for a digit
digit = 1
else:
print("password doesn't contain at least one number")
  
# checks each character for a lowercase letter
elif password[i].islower() == True:
lower = 1
continue
else:
print("password doesn't contain a lowercase letter")

# checks each character for a uppercase letter
elif password[i].isupper() == True:
upper = 1
continue
else:
print("password doesn't contain an uppercase letter")

# checks the length of the character
elif len(password) > 7:
length = 1
continue
else:
print("password doesn't have 8 or more characters")

# checks each character for a symbol
elif password[i] == '!' or '@'or '$' or '%' or '&' or '_' or '=':
symbol = 1
continue
else:
print("password doesn't have a symbol (!@$%&_=)")
break


def main():
#Prompt user for password entry
password = input("Please enter a password. Password must follow
password policy: ")

policy(password) # call function
  
main()

Explanation / Answer

def policy(password):
digit = 0
upper = 0
lower = 0
symbol = 0
length = 0
for i in range(0, len(password)):
if password[i].isdigit():
digit++;

continue

if password[i].islower():
lower++;

continue

if password[i].isupper():

upper++

continue
if len(password) > 7:
length = 1
continue

if password[i] == '!' or '@'or '$' or '%' or '&' or '_' or '=':
symbol = 1
continue

if !digit>=1:

print('password should contain atleast one digit')

if !upper>=1:

print('password should contain atleast one uppercase')

if !lower>=1:

print('password should contain atleast one lowercase')

if !symbol>=1:

print('password should contain atleast one special symbol')

if length!=1:

print('password should contain have minimum 8 characters')

def main():
#Prompt user for password entry
password = input("Please enter a password. Password must follow
password policy: ")

policy(password) # call function
  
main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote