forked from Ada-Activities/errors-and-debugging
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntax.py
More file actions
27 lines (25 loc) · 662 Bytes
/
syntax.py
File metadata and controls
27 lines (25 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def map_character_frequency(words):
print("Input words:", words) # 🛠 调试输入
char_map = {}
for word in words:
for character in word:
if character not in char_map:
char_map[character] = 1
else:
char_map[character] += 1
return char_map
def test_map_character_frequency():
colors = ["red", "orange"]
char_map = map_character_frequency(colors)
expected = {
"r": 2,
"e": 2,
"d": 1,
"o": 1,
"a": 1,
"n": 1,
"g": 1,
}
assert char_map == expected
def syntax_errors():
test_map_character_frequency()