def test_count_words(self): self.assertEqual({ 'apple': 2, 'pie': 1, 'banana': 1 }, count_words(["apple", "banana", "apple", "pie"])) self.assertEqual({ 'ruby': 1, 'python': 3 }, count_words(["python", "python", "python", "ruby"])) self.assertEqual({}, count_words([]))
def test_count_words(self): self.assertEqual({'apple': 2, 'pie': 1, 'banana': 1}, count_words(["apple", "banana", "apple", "pie"])) self.assertEqual({'ruby': 1, 'python': 3}, count_words(["python", "python", "python", "ruby"])) self.assertEqual({}, count_words([]))
def test_count_words(self): d = {"apple": 2, "banana": 1, "pie": 1} self.assertDictEqual(d, count_words(["apple", "banana", "apple", "pie"]))
def unique_words_count(arr): return len(count_words(arr))