Skip to content

Commit 0f4251e

Browse files
author
boraxpr
committed
bux fix
1 parent 7afd79b commit 0f4251e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

180/names.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,31 @@
1717
def group_names_by_country(data: str = data) -> defaultdict:
1818
countries = defaultdict(list)
1919
# you code
20+
words=[]
21+
counter=0
22+
for line in data.split():
23+
for word in line.split(',', 2):
24+
words.append(word)
25+
words.remove('last_name')
26+
words.remove('first_name')
27+
words.remove('country_code')
28+
# print(words)
29+
for word in words:
30+
if len(word)==2:
31+
name = firstname + " " + lastname
32+
countries[word].append(name)
33+
continue
34+
if counter%2==0:
35+
lastname = word
36+
counter=1
37+
continue
38+
if counter%2==1:
39+
firstname = word
40+
counter=0
41+
continue
2042
return sorted(countries.items())
2143

44+
45+
46+
47+
# print(group_names_by_country())

180/test_names.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ def test_grouping2_return(grouping2, key, expected):
6464

6565
test_grouping1_return
6666
test_grouping2_return
67+
test_return_type(grouping1,grouping2)
68+
test_return_dict_len(grouping1,grouping2)

0 commit comments

Comments
 (0)