Unit 3 Task 18: Election-style tally

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 3 Task 18 - Election-style tally

← Unit 3 tasks - Solution


Allowed options are three strings in a list in your code, e.g. ["pizza", "pasta", "salad"].

Ask the user to vote repeatedly until they type done. Only accept votes that are one of the options (case-insensitive); otherwise print Invalid vote and do not count.

Store each valid vote in a list (optional for audit) and maintain a dictionary option -> vote count.

At the end, print how many votes each option got and which option won (highest count; you may assume a unique winner).

Skills: lists, dicts, validation, finding max by looping over dict items.