File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ def binary_count_trailing_zeros(a: int) -> int:
1717 >>> binary_count_trailing_zeros(4294967296)
1818 32
1919 >>> binary_count_trailing_zeros(0)
20- 0
20+ Traceback (most recent call last):
21+ ...
22+ ValueError: Input value must be a positive integer
2123 >>> binary_count_trailing_zeros(-10)
2224 Traceback (most recent call last):
2325 ...
@@ -31,11 +33,11 @@ def binary_count_trailing_zeros(a: int) -> int:
3133 ...
3234 TypeError: '<' not supported between instances of 'str' and 'int'
3335 """
34- if a < 0 :
35- raise ValueError ("Input value must be a positive integer" )
36- elif isinstance (a , float ):
36+ if isinstance (a , float ):
3737 raise TypeError ("Input value must be a 'int' type" )
38- return 0 if (a == 0 ) else int (log2 (a & - a ))
38+ if a < 0 or a == 0 :
39+ raise ValueError ("Input value must be a positive integer" )
40+ return int (log2 (a & - a ))
3941
4042
4143if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments