- Create an empty list: animal_list . Look at page 38 from the book for an example how to create an empty list.
- Ask user 4 times (input from shell): “Enter animal name: “
- Add these 4 animal names into the animal_list list.
- After this, create a for loop and loop through every animal in the list and print to the shell. If the animal is “dog”, print “dog” or “cat” is my favorite animal. This is very similar to what we have done in the class.
- Example 1
Enter animal name: whale
Enter animal name: dolphin
Enter animal name: dog
Enter animal name: lion
You have entered the following animals:
whale
dolphin
dog is my favorite animal
lion
- Example 2
Enter animal name: tiger
Enter animal name: dog
Enter animal name: elephant
Enter animal name: cat
You have entered the following animals:
tiger
dog is my favorite animal
elephant
cat is my favorite animal