Skip to content

Commit a280191

Browse files
committed
Updated octal_to_decimal.py
1 parent e3e2f23 commit a280191

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

conversions/octal_to_decimal.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def oct_to_decimal(oct_string: str) -> int:
2121
is_negative = oct_string[0] == "-"
2222
if is_negative:
2323
oct_string = oct_string[1:]
24-
if not all(0 <= int(char) <= 7 for char in oct_string):
24+
if not oct_string.isdecimal() or not all(
25+
0 <= int(char) <= 7 for char in oct_string
26+
):
2527
raise ValueError("Non-octal value was passed to the function")
2628
decimal_number = 0
2729
for char in oct_string:

0 commit comments

Comments
 (0)