logo CodeStepByStep logo

count_names

Language/Type: Python collections dict

Write a complete console program that asks the user for a list of names (one per line) until the user enters a blank line (i.e., just presses Enter when asked for a name). At that point, the program should print out how many times each name in the list was entered. A sample run of this program is shown below.

Enter name: Alice
Enter name: Bob
Enter name: Alice
Enter name: Chelsea
Enter name: Bob
Enter name: Alice
Enter name:
Entry [Alice] has count 3
Entry [Bob] has count 2
Entry [Chelsea] has count 1
Type your Python solution code here:

This exercise asks for bare code. Submit a fragment of Python code as described. Do not write any class or function/method heading around your code; just write the lines of code that will produce the result described.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.