File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 571
571
* [ Largest Subarray Sum] ( maths/largest_subarray_sum.py )
572
572
* [ Least Common Multiple] ( maths/least_common_multiple.py )
573
573
* [ Line Length] ( maths/line_length.py )
574
+ * [ Liouville Lambda] ( maths/liouville_lambda.py )
574
575
* [ Lucas Lehmer Primality Test] ( maths/lucas_lehmer_primality_test.py )
575
576
* [ Lucas Series] ( maths/lucas_series.py )
576
577
* [ Maclaurin Series] ( maths/maclaurin_series.py )
Original file line number Diff line number Diff line change @@ -17,16 +17,19 @@ def get_1s_count(number: int) -> int:
17
17
>>> get_1s_count(-1)
18
18
Traceback (most recent call last):
19
19
...
20
- ValueError: the value of input must be positive
20
+ ValueError: Input must be a non-negative integer
21
21
>>> get_1s_count(0.8)
22
22
Traceback (most recent call last):
23
23
...
24
- TypeError: Input value must be an 'int' type
24
+ ValueError: Input must be a non-negative integer
25
+ >>> get_1s_count("25")
26
+ Traceback (most recent call last):
27
+ ...
28
+ ValueError: Input must be a non-negative integer
25
29
"""
26
- if number < 0 :
27
- raise ValueError ("the value of input must be positive" )
28
- elif isinstance (number , float ):
29
- raise TypeError ("Input value must be an 'int' type" )
30
+ if not isinstance (number , int ) or number < 0 :
31
+ raise ValueError ("Input must be a non-negative integer" )
32
+
30
33
count = 0
31
34
while number :
32
35
# This way we arrive at next set bit (next 1) instead of looping
You can’t perform that action at this time.
0 commit comments