PYTHON. Create a function that accepts a filename where in each line there is a name...

90.2K

Verified Solution

Question

Programming

PYTHON. Create a function that accepts a filename wherein each line there is a name of a type of bird. use a pythondictionary in order to count the # of time each bird appears. (1line = 1 appearance) Loop over your dict. to print each speciesand the # of times it was seen in the file once all lines have beencounted. return dictionary containing count

the filename opens this:

blackbird

canary

hummingbird

canary

hummingbird

canary

example of outcome. Blackbird,1

Hummingbird,2

Canary,3

Answer & Explanation Solved by verified expert
4.5 Ratings (833 Votes)
Here is the code in pythonfilename inputEnter filename reading all lines from the file and adding to a listwith openfilenamer as f    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students