Question: Write a Python script to parse the provided file animals.txt. Use Regular Expressions, import re Parse each line of the file. If the line starts
Write a Python script to parse the provided file animals.txt.

Use Regular Expressions, import re
Parse each line of the file.
If the line starts with # ignore it.
If the line has this organization: has .
1. Add the number to the dictionary perperson[name].
2. Add the number to the dictionary animaltypecount[animaltype]
After Parsing the file print the following:
1.Print the names of all people with pets. Avoid printing duplicates.
Ex. Jesse has 2 pet(s).
2.Print the number of pets per animal type.
Ex. There are 3 dog(s).
animals.txt this is a comment - ignore me George has 5 giraffe Ryan has 3 snake. Lisa has 7 cat. Melonie has 12 horse. #Tristan has 1 dog Tommy has 1 dog Tammy has 4 elephant. SueAnne has 5 cat. Aaron has 3 dog Sharon has 2 cat. Ralph has 1 snake. Tim has 2 dog #This is the last line. animals.txt this is a comment - ignore me George has 5 giraffe Ryan has 3 snake. Lisa has 7 cat. Melonie has 12 horse. #Tristan has 1 dog Tommy has 1 dog Tammy has 4 elephant. SueAnne has 5 cat. Aaron has 3 dog Sharon has 2 cat. Ralph has 1 snake. Tim has 2 dog #This is the last line
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
