Skip to content

Commit b64cf60

Browse files
author
boraxpr
committed
bite 26
1 parent 328d884 commit b64cf60

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

26/exclude.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
bites = {6: 'PyBites Die Hard',
2+
7: 'Parsing dates from logs',
3+
9: 'Palindromes',
4+
10: 'Practice exceptions',
5+
11: 'Enrich a class with dunder methods',
6+
12: 'Write a user validation function',
7+
13: 'Convert dict in namedtuple/json',
8+
14: 'Generate a table of n sequences',
9+
15: 'Enumerate 2 sequences',
10+
16: 'Special PyBites date generator',
11+
17: 'Form teams from a group of friends',
12+
18: 'Find the most common word',
13+
19: 'Write a simple property',
14+
20: 'Write a context manager',
15+
21: 'Query a nested data structure'}
16+
exclude_bites = {6, 10, 16, 18, 21}
17+
18+
19+
def filter_bites(bites=bites, bites_done=exclude_bites):
20+
"""return the bites dict with the exclude_bites filtered out"""
21+
filtered_dict = {k: v for (k, v) in bites.items() if k not in exclude_bites}
22+
return filtered_dict
23+
24+
print(filter_bites())

26/test_exclude.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from exclude import filter_bites, exclude_bites
2+
3+
4+
def test_filter_bites():
5+
result = filter_bites()
6+
assert type(result) == dict
7+
assert len(result) == 10
8+
for bite in exclude_bites:
9+
assert bite not in result, f'Bite {bite} should not be in result'
10+
11+
test_filter_bites()

0 commit comments

Comments
 (0)