Question: 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

 Write a program, in a file named count_items.py , which does

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!