# Arup Guha
# 11/2/2020
# Solution to COP 2930 Program #8 Part A: Number List Program

QUIT = 4

# Just prints the menu and returnst he user's choice.
def menu():
    print("What selection would you like to make?")
    print("1. Add a number")
    print("2. Remove a number")
    print("3. Print the list")
    return int(input("4. Quit\n"))

# Runs the main program.
def main():

    # Get the user's choice.
    choice = menu()

    # Set up my empty list.
    mylist = []
    
    # Go till they quit.
    while choice != QUIT:

        # Add.
        if choice == 1:

            # Get the number and add it to the end.
            val = int(input("What number do you want to add?\n"))
            mylist.append(val)
            print("Your number has been added.\n")

        # Remove
        elif choice == 2:

            # Get the number.
            val = int(input("What number do you want to remove?\n"))

            # Remove if it's in the list
            if val in mylist:
                mylist.remove(val)
                print("Your number has been removed.\n")

            # Error message.
            else:
                print("Sorry, that number is not on the list.\n")

        # Print the list.
        elif choice == 3:
            print("Your list is", mylist,"\n")

        # Error messages, not needed for the assignment.
        else:
            print("Sorry, that was not a valid selection.")

        # Get the user's next choice.
        choice = menu()

    # Ending greeting.
    print("Thank you for using the list generator!")

# Run it!
main()
