Apr-24-2020, 10:05 PM
You call new_account_1() recursively if the user types in a username that is already in use.
I think you will face similar problems with recursively calling start_1()
Recursion is not a good tool for this problem. Looping is a better fit.
def new_account_1(): #aything below is what will happen when we use new_account() command new_username_1 = input ("What do you want to set your username as: ") #ask user to input a new username username_taken_check_1 = os.path.isfile("E:/Work/School/Computer Science/Python/Code/School Work/User Info/" + new_username_1 + ".txt") #checks if the file exists if username_taken_check_1 == True: #is it returns as true and the file does exist print ("This username is already taken, please try again") #tells you the username has already been taken new_account_1() # <-- Recursively call again elif username_taken_check_1 == False: #if it returns as false and the file dosent exist print ("Okay your new username is, " + new_username_1) #tells them what the new username isYou are seeing the password asked for twice because you called new_account_1() twice, once from inside start1() and once from inside new_account_1(). If the user entered two invalid usernames the program would ask for a password three times, one each for the invalid usernames and one for the valid username. If the program actually created a user account, it would create accounts for the invalid usernames. What a mess!
I think you will face similar problems with recursively calling start_1()
Recursion is not a good tool for this problem. Looping is a better fit.
username_taken = True while username_taken: new_username_1 = input ("What do you want to set your username as: ") #ask user to input a new username username_taken = os.path.isfile( "E:/Work/School/Computer Science/Python/Code/School Work/User Info/" \ + new_username_1 + ".txt") #checks if the file exists if username_taken: print ("This username is already taken, please try again") #tells you the username has already been takenThis will loop until an unused username is entered. No mater how many times the user enters an invalid password it still only creates one account and only asks for one password