I have been working on a project that uses a database. It makes the user choose from the commands in the program. The program makes you add your password, E-mail, user id, and birthday, and every user has his own user id. He can make a new user, delete password, delete user, change password and change user id.
Every option has its own command, but there a problem appeared to me while I was working.
I made a input variable and named it (Command option) that prints a message which tells the user to write the command he wants to use, I also made an If condition which is the variable (Command option) == "N" or "n" to create new user, and I made an else if condition that if the variable (Command option) isn't equal "N" or "n" to print
("Sorry, we don't have this command"),
but the problem is that if I put the condition to make a new user before the condition ; to print, doesn't work, even if the variable (Command option) isn't equal to "N" or "n", and if I do the opposite to put the condition to print before the condition to make a new user, the condition to make new a user doesn't work, even if the variable (Command option) equals "N" or "n" so, what's the problem?
def create_new_user():
print(Fore.BLUE + "Please, Enter the following data so we could add it to the database: ") u_id = input(Fore.YELLOW + "user_id: ") p_t = input(Fore.YELLOW + "password [text]: ") e_t = input(Fore.YELLOW + "Email [text]: ") b_t = input(Fore.YELLOW + "birthday [integer]: ") cursor.execute(""" INSERT INTO data (user_id, password, Email, birthday) VALUES (?, ?, ?, ?) """, (u_id, p_t, e_t , b_t)) db.commit() print ('Data entered successfully.') if (db.commit): db.close () print("The connection is closed.")Command_option = input(Fore.YELLOW + "Please enter the command you want to use: ")
if Command_option == "N" or Command_option == "n":
create_new_user()
else:
raise Exception(Fore.RED + f"Sorry, we don't have this command :(")