Read Hex Numbers

Hexadecimal numbers often appear in colors, memory addresses, and low-level data. The function hexa receives a string hex_string and converts it to a decimal number, ignoring letter case. If the string contains a character that is not valid in hexadecimal notation, raise ValueError.

Примеры

Ввод
"1"
Вывод
1
Ввод
"10"
Вывод
16
Ввод
"2f"
Вывод
47

Нужно реализовать

def hexa(hex_string: str) -> int:

Теги

mathstrings
PostgreSQLv16

Taispeánfar toradh do chóid anseo

Visible tests
1
Input
"1"
Expected1
2
Input
"10"
Expected16
3
Input
"2f"
Expected47
4
Input
"ff"
Expected255
5
Input
"a1"
Expected161
6
Input
"cafe"
Expected51966
Focus radio
Paused · SomaFM · Fluid