Oct-15-2017, 11:08 PM
Hey so my code is about a username and password system. My issue is that after the user fails to input the correct details (from Intro) more than once it appears with the same message. What should be happening is that when attempt = 2, it should say you have 1 more attempt. If they entered the wrong details again, the message you have entered 3 times and you are now locked out, contact the network office. This is part is in Username_Submit(name). Doesn't appear with an actual error, I think it justs loops over.
import time def intro(): #Username and Password is displayed print("Hello, your username is: Greg232 ") time.sleep(1) print("Your password is: userword657") Username_verify() def Username_verify(): name = Username_Name() proceed = Username_Submit(name)#Prints the credientals the user has put in print(proceed) def Username_Name(): #User must input the correct username and password given to them name=list() username = input('Username: ') double_check = input('Are you sure? ') if double_check != 'yes': Username_Name() #If they say anything other than yes they will need to input their username again if double_check == 'yes': print('Proceed...') name.append(username) password = input("Password: ") double_check = input('Are you sure? ') if double_check != 'yes': return double_check name.remove(Username_Name()) if double_check == 'yes': name.append(password) #If the user says yes then Username_Submit(name) will check they match with the #correct credientials if Username_Submit(name) != 'Greg232' and 'userword657': name.remove(Username_Name()) return name def Username_Submit(name): attempt = 1 print(name[0], name[1]) Submit = input("Submit?") #Double checks that the user is ok with what they entered if Submit == 'yes': if name[0] == 'Greg232' and name[1] == 'userword657': print("You may enter the system...")#User inputs correct username and password else: #therefore they can enter the system while name[0] != 'Greg232' and name[1] != 'userword657' and attempt == 1: attempt = attempt + 1 #Username or/and password is not correct, they have 2 more attempts print("Your username or password is wrong.") print("You have 2 more attempts left. ") Username_Name() print(name[0], name[1]) Submit = input("Submit?") if Submit == 'yes': if name[0] == "Greg232" and name[1] == "userword657" and attempt == 1: print("You may enter the system...")#User can retry typing in the correct details elif name[0] != 'Greg232' and name[1] != 'userword657' and attempt == 2: attempt = attempt + 1 print("You have 1 more attempt left.") Username_Name() #Everytime the user inputs the wrong log-in details, #a message will appear with the amount of attempts remaining elif name[0] != 'Greg232' and name[1] != 'userword657' and attempt == 3: print("You have entered 3 attempts and you are now locked out,") print("contact the network office.") else: Username_Name() #If user does not say yes they must re-enter their details intro()