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

You work for an on-line game site. Your job is to develop a program that accepts

ID: 3810051 • Letter: Y

Question

You work for an on-line game site. Your job is to develop a program that accepts a user name and password. Write a Python script that prompts users for a user name and password. a. The user name should be at least 6 characters long and is stored in a list such that it can't be used again. b. The password can only be validated if the following conditions are met: At least 1 letter between [a-z] and 1 letter between [A-Z]. At least 1 number between [0-9]. At least 1 character from [S#@]. Minimum length 6 characters. Maximum length 16 characters.

Explanation / Answer

Code:
Plese check indentation

data={}
num=['1','2','3','4','5','6','7','8','0']
lowers=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

uppers=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']


def check_pass(passw):
if('$' in passw or '#' in passw or '@' in passw):
flag4=0
if(len(passw)<6 or len(passw)>16):
return -1
flag1=0
for elem in lowers:
if(elem in passw):
flag1=1
break
flag2=0
for elem in uppers:
if(elem in passw):
flag2=1
break
  
flag3=0
for elem in num:
if(elem in passw):
flag3=1
  
if(flag1==0):
return -1
if(flag2==0):
return -1
if(flag3==0):
return -1
if(flag4!=0):
return -1;
return 1;
  

name=input("Please enter your username: ")

while(len(name)<6):
name=input("Please enter username (at least 6 characters): ")

passw=input("Please enter your password: ")
while(check_pass(passw)==-1):
passw=input("Please enter valid password: ")
  
if(name in data):
print("This name is already in database")
else:
data[name]=passw

print("Your username and password has been added")
  

Output:

Please enter your username: abababa

Please enter your password: ABC123a$
Your username and password has been added

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