Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python script to parse the provided file (below) Parse each line of the file. If the line starts with # ignore it. If

Write a Python script to parse the provided file (below)

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).

txt file:

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions