Q. Write a program that asks a new user about userid and password and then appends it to file “security. txt” provided the give userid does not exist in the file . If it does, then display error message “User id already exist”and prompt the user to re-enter the userid. Also, make sure that the password is a least 8 characters long with at least a digit and a special character out of “$, @and %” in it.
Answer =
def password():
psd= input ("Enter the password :- ")
if len(psd) >= 8 and ("$" in psd or "@" in psd or "%" in psd):
print (" Done ")
file.write(userid + " " + psd + "\n")
else :
print ("Re-enter the password")
password()
file = open("security.txt","r+")
text = file.readlines()
userid = input("Enter userID : - ")
same = 0
for i in text:
line = i.split()
if line[0] == userid:
same = 1
print ("User id already exist")
if same == 0 :
password()
file.close()
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletealan george son jorphy friend
ReplyDeletestop it i am feeling offended plss
ReplyDeletesuck it
Deleteganja kai alan
ReplyDeleteoii alysha das
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )