Trying to create a function(python) that looks at a list of strings, takes input, then based on the input, either(appends, pops, quits, removes items)
13:39 25 Mar 2026

im not sure why "quit" doesn't quit the function, and im getting an error when a space/nothing is entered while there is stillone string left in the list.

Here is my code so far..

animal_list = ["cat", "wolf", "horse"]

def listomatic():
    #animal = input("Enter the name of an animal or 'quit' to quit: ")
    while animal_list != []:
        #list = ["cat", "wolf", "horse"]
        animal = input("Enter the name of an animal or 'quit' to quit: ")
        if animal == "":
            print("Welcome name. Look at this list of animals : ", animal_list, "\n")
            animal_list.pop()
            popped_animal = animal_list.pop()
            print_this3 = print("Enter the name of an animal: ", animal, "\n",
                                popped_animal, "was popped from list")
            #return print_this3
        elif animal == "quit":
            print_this4 = print("Welcome name. Look at this list of animals : ", list, "\n",
                                "Enter the name of an animal: ", animal, "\n",
                                "Goodbye!")
            return
        elif animal in animal_list:
            print("Welcome name. Look at this list of animals: ", animal_list)
            animal_list.remove(animal)
            print_this1 = print(#"Welcome name. Look at this list of animals: ", animal_list, "\n", 
                                "Enter the name of an animal: ", animal, "\n", 
                                "1 instance of " + animal + " removed from list")
            #return print_this1
        elif animal not in animal_list:
            print("Welcome name. Look at this list of animals: ", animal_list, "\n")
            animal_list.append(animal)
            print_this2 = print(#"Welcome name. Look at this list of animals: ", animal_list, "\n", 
                                "Enter the name of an animal: ", animal, "\n", 
                                "1 instance of " + animal + " appended to list")
            #return print_this2
         
            #break
        else:
            print("Goodbye!")
            
            break
            
            
listomatic()
python