In [1]:
import random  #Allows you to have random numbers, symbols and characters. It is also a built-in module.
import string  #Alllows you to import strings. It is also a built-in module.

#Defining function
def generator_password(size):
    #Define the password's characters
    characters = string.ascii_letters + string.digits + string.punctuation

    #Generate your password with choices of characters, digits and punctuations
    password = ''.join(random.choice(characters)for i in range(size))
    #return your password, which sends the result of the code back
    return password

#Continues to run until exit. Runs with the menu screen
while True:
    menu_screen = print("Menu Screen:") #menu_screen trying to make list
    choice_one = print("1. View your password") #option one of the list that lets you view your passwords
    choice_two = print("2. Generate a new passoword") #option two of the list that lets you make a new password
    choice_three = print("3. Exit") #option 3 lets you exit the program
    
    choice = input("Enter:1,2,3:   ") #lets the user input their choice

    #Choice one that lets you check the passwords you have
    if choice == "1":
        with open("Passwords.txt","r") as f: #Opens up text file to check you passwords
            passwords = f.read() #Reads the text file of your passwords with many characters
            print(passwords) #Prints your passwords in the text file
        
    #Choice two makes a new password
    elif choice == "2": 
        program = input("What progam do you want our password for?     ") #Asking what program the password is for
        size = int(input("How many characters do you want the password?    ")) #Asking the amount of characters you want in you password
        password = generator_password(size) #Variable that is equal to the password's size, which was the defined function above
        print(f"The password for {program} is {password}") #Statement with the format that will be the the text file
        
        with open("Passwords.txt","+a") as f: #Opens the text file
            f.write(f"{program}: {password}\n") #Writes in the text file of what you inputted
    
    #Choice three that exits the program
    elif choice =="3":
        print("Have a Good Day!!!") #Good Bye note when program ends
        break #Ends the program
Menu Screen:
1. View your password
2. Generate a new passoword
3. Exit
Enter:1,2,3:   3
Have a Good Day!!!
In [ ]:
 
In [ ]: