#C14235. Word Frequency Counter
Word Frequency Counter
Word Frequency Counter
You are given a list of items provided via standard input. The first line contains an integer n which indicates the number of items. Each of the following n lines contains a Python literal; a valid string will be enclosed in either single or double quotes, while non‐string literals (such as numbers or None) will not be quoted. Your task is to count the frequency of each valid string (ignoring case) and output a Python dictionary representation.
Note: The function should discard any literal that is not a string. Also, do not trim any leading or trailing whitespace within the string; consider the content within the quotes as is once evaluated.
For example, given the list:
["Apple", "banana", "apple", "Banana", "APPLE"]
the dictionary should be:
{'apple': 3, 'banana': 2}
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer n, the number of items.
- The following n lines each contain a Python literal. A valid string literal will be enclosed in single (') or double (") quotes. Non-string literals (e.g. numbers, None, etc.) are not quoted.
outputFormat
Output a single line to standard output (stdout) containing the dictionary (in Python dictionary format) whose keys are the lowercased valid strings found in the input and whose values are their corresponding counts.
For example, an output could be: {'apple': 3, 'banana': 2}
5
"Apple"
"banana"
"apple"
"Banana"
"APPLE"
{'apple': 3, 'banana': 2}