Skip to content

Commit 47bf3f5

Browse files
alexpantyukhingithub-actions
and
github-actions
authored
fix validation condition and add tests (TheAlgorithms#7997)
* fix validation condition and add tests * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 361ddaf commit 47bf3f5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: bit_manipulation/index_of_rightmost_set_bit.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@ def get_index_of_rightmost_set_bit(number: int) -> int:
1919
Traceback (most recent call last):
2020
...
2121
ValueError: Input must be a non-negative integer
22+
>>> get_index_of_rightmost_set_bit('test')
23+
Traceback (most recent call last):
24+
...
25+
ValueError: Input must be a non-negative integer
26+
>>> get_index_of_rightmost_set_bit(1.25)
27+
Traceback (most recent call last):
28+
...
29+
ValueError: Input must be a non-negative integer
2230
"""
2331

24-
if number < 0 or not isinstance(number, int):
32+
if not isinstance(number, int) or number < 0:
2533
raise ValueError("Input must be a non-negative integer")
2634

2735
intermediate = number & ~(number - 1)

0 commit comments

Comments
 (0)