Spaces:
Sleeping
Sleeping
Deploy: tasks/type_errors/type_error_2.json
Browse files
tasks/type_errors/type_error_2.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": "type_errors-2",
|
| 3 |
+
"difficulty": "type_errors",
|
| 4 |
+
"description": "Fix the function to count frequencies. It incorrectly calls .append() on a dict.",
|
| 5 |
+
"buggy_code": "def count_frequencies(words):\n counts = {}\n for word in words:\n if word not in counts:\n counts.append({word: 1})\n else:\n counts[word] += 1\n return counts",
|
| 6 |
+
"test_code": "\nimport unittest\nclass TestTypeError2(unittest.TestCase):\n def test_normal(self):\n self.assertEqual(count_frequencies(['apple', 'banana', 'apple']), {'apple': 2, 'banana': 1})\n def test_empty(self):\n self.assertEqual(count_frequencies([]), {})\n",
|
| 7 |
+
"optimal_time_seconds": 0.05
|
| 8 |
+
}
|