Demo entry 6662813

functionss

   

Submitted by anonymous on Nov 27, 2017 at 19:12
Language: Python 3. Code size: 1.3 kB.

#menu() is the main function of the program. The user has the choice of what to do here. Also, the user always has the choice to return to this menu is necessary.

def menu():
    choice = input("Welcome to the Password Checker and Generator. \n Do you want to \n 1) Check password. \n 2) Generate Password \n 3) Quit.")

    if choice == '1' : #if the user chooses to check password, the check() function is called. This checks the password.
        check()

    elif choice == '2' :  #if the user chooses to generate password, the generate() function is called. This generates a password.
        generate()

    elif choice == '3' : #if the user chooses to quit, the quitfun() function is called. This allows the user to quit the program.
        quitfun()

    else :
        print ("Please choose either 1,2 or 3.")

        choice2 = input("Do you want to \n 1) Choose again \n 2) Exit") #this gives the user another go if they don't choose either 1, 2 or 3.
        if choice2 == '1':

            menu()

        elif choice2 == '2':  #this gives the user the choice to quit.
            print("Thank you for using the Password Checker and Generator.")
            return
            sys.exit

        else :
            print ("Please choose either 1 or 2.")

        menu()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).