Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conversions/octal_to_hexadecimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def octal_to_hex(octal: str) -> str:
'0x40'
>>> octal_to_hex("235")
'0x9D'
>>> octal_to_hex("0")
'0x0'
>>> octal_to_hex(17)
Traceback (most recent call last):
...
Expand Down Expand Up @@ -42,7 +44,7 @@ def octal_to_hex(octal: str) -> str:
revhex += hex_char[decimal & 15]
decimal >>= 4

return "0x" + revhex[::-1]
return "0x" + (revhex[::-1] or "0")


if __name__ == "__main__":
Expand Down
Loading