File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,18 +22,25 @@ def binary_and(a: int, b: int) -> str:
2222 >>> binary_and(0, -1)
2323 Traceback (most recent call last):
2424 ...
25- ValueError: the value of both inputs must be positive
25+ ValueError: the value of both inputs must be non-negative
2626 >>> binary_and(0, 1.1)
2727 Traceback (most recent call last):
2828 ...
29- ValueError: Unknown format code 'b' for object of type 'float'
29+ TypeError: both inputs must be integers
3030 >>> binary_and("0", "1")
3131 Traceback (most recent call last):
3232 ...
33- TypeError: '<' not supported between instances of 'str' and 'int'
33+ TypeError: both inputs must be integers
34+ >>> binary_and(10, "1")
35+ Traceback (most recent call last):
36+ ...
37+ TypeError: both inputs must be integers
3438 """
39+ if type (a ) is not int or type (b ) is not int :
40+ raise TypeError ("both inputs must be integers" )
41+
3542 if a < 0 or b < 0 :
36- raise ValueError ("the value of both inputs must be positive " )
43+ raise ValueError ("the value of both inputs must be non-negative " )
3744
3845 a_binary = format (a , "b" )
3946 b_binary = format (b , "b" )
You can’t perform that action at this time.
0 commit comments