File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -54,29 +54,29 @@ def reverse_bit(number: int) -> int:
5454 >>> reverse_bit(1.1)
5555 Traceback (most recent call last):
5656 ...
57- TypeError: input value must be an 'int' type
57+ TypeError: Input value must be an 'int' type
5858
5959 >>> reverse_bit("0")
6060 Traceback (most recent call last):
6161 ...
62- TypeError: input value must be an 'int' type
62+ TypeError: Input value must be an 'int' type
6363 """
6464 if not isinstance (number , int ):
65- raise TypeError ("input value must be an 'int' type" )
66- elif number < 0 :
67- raise ValueError ("the value of input must be non-negative" )
65+ raise TypeError ("Input value must be an 'int' type" )
66+ if number < 0 :
67+ raise ValueError ("The value of input must be non-negative" )
6868
6969 result = 0
70- # iterator over [1 to 32], since we are dealing with a 32- bit integer
70+ # iterator over [1 to 32], since we are dealing with a 32 bit integer
7171 for _ in range (32 ):
7272 # left shift the bits by unity
73- result = result << 1
73+ result <<= 1
7474 # get the end bit
7575 end_bit = number & 1
7676 # right shift the bits by unity
77- number = number >> 1
77+ number >>= 1
7878 # add that bit to our ans
79- result = result | end_bit
79+ result |= end_bit
8080 return result
8181
8282
You can’t perform that action at this time.
0 commit comments