Skip to content

Commit 62d438c

Browse files
fix:bucket count type
1 parent f5988cc commit 62d438c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

sorts/bucket_sort.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ def bucket_sort(my_list: list, bucket_count: int = 10) -> list:
7171
>>> data = [9, 2, 7, 1, 5]
7272
>>> bucket_sort(data) == sorted(data)
7373
True
74+
>>> bucket_sort(data, 3.5)
75+
Traceback (most recent call last):
76+
...
77+
TypeError: bucket_count must be an integer
7478
"""
75-
79+
if type(bucket_count) != int:
80+
raise TypeError("bucket_count must be an integer")
7681
if len(my_list) == 0 or bucket_count <= 0:
7782
return []
7883

0 commit comments

Comments
 (0)