Question: Lab02 - Exercise - Count (1 point) Open count.py and read the documentation for stub function count_char(). To better understand what the function needs to


Lab02 - Exercise - Count (1 point) Open count.py and read the documentation for stub function count_char(). To better understand what the function needs to do, write further tests in test_count.py. Each test should be its own function. Once you're satisfied you have a good set of tests, implement the count_char() function. Run your tests to ensure they pass. def count_char(input): Counts the number of occurrences of each character in a string. The result should be a dictionary where the key is the character and the dictionary is its count. For example, >>> count_char("Hello0o!") {'H': 1, 'e': 1, 'l': 2, 'o': 2, 'O': 1, '!': 1) from count import count_char def test_empty(): assert count_char("") def test_simple(): assert count_char("abc") == {"a": 1, "b": 1, "c": 1} def test_double(): assert count_char("aa") == {"a": 2}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
