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

I\'m in the process of learning Python, but I\'m still very new and having some

ID: 3864805 • Letter: I

Question

I'm in the process of learning Python, but I'm still very new and having some difficulty. I came across a practice example, that I could use some help with.

Write a program for user registration:
• First the program tells the user “enter 1 to register, enter 2 to sign in, enter 3 to quit”
• After the user enter 1, the program ask the user to input username and password, the

username can not be the same as any existing ones.

• After registration, tell user “Congratulations! You have an account with us” direct

user back to the starting point.

• If the user enter 2, hint the user either “Wrong password” or “Wrong username”

until user enters a correct combination

• Display “Welcome back to your account!” after user entered the correct user name

and password.

Explanation / Answer

#i have used Dictonary so that no duplicate username will be there in the dictonary

def enterChoice():
choice= input(" enter 1 to register, enter 2 to sign in, enter 3 to quit");
return choice
user=dict()
choice=enterChoice()
while(int(choice)!=3):
  
if int(choice)==1:
  
username= input(" enter username")
password= input("enter password")
user[username]=password
print("Congratualtion you have account with us")
enterChoice()
elif int(choice)==2:
username=input('enter username ')
if username in user.keys():
password=input('enter password')
if password== user[username]:
print("welcome back to account")
else :
print("Wrong password")
enterChoice()
else :
print("Wrong username")
enterChoice()
  
  
  

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