Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program, in a file named count_items.py , which does the following: As with the population program, use input() to read a filename from

image text in transcribed

Write a program, in a file named count_items.py , which does the following: As with the population program, use input() to read a filename from the keyboard; open the file, and read its contents. (Use the prompt File to scan: for this input.) The input format is similar to the Population problem you just did; however, in this case, you can assume that the string will only have only one word (it will never have spaces in it). So make sure to remove leading and trailing whitespace, skip over comments, and ignore blank lines. But after you've handled all of this, each line will be string integer Your job will be to print out the totals, ordered first by the count, and (if there are duplicate counts), ordered by the word. EXAMPLE If your input looks like this: asdf 10 jkl 3 asdf -1 foobar 17 bbbb 17 then the last step of your output should be: jkl 3 asdf 9 bbbb 17 foobar 17

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

Students also viewed these Databases questions