New Base to Number

A string like FF can represent a regular number once you know its numeral system. Given a string text and a base from 2 to 16, convert the value from that base into a decimal integer. Return the resulting integer.

Примеры

Ввод
"101", 2
Вывод
5
Ввод
"0", 2
Вывод
0
Ввод
"FF", 16
Вывод
255

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

def base_to_int(text: str, base: int) -> int:

Теги

math
PostgreSQLv16

Your code output will appear here

Visible tests
1
Input
"101", 2
Expected5
2
Input
"0", 2
Expected0
3
Input
"FF", 16
Expected255
4
Input
"1010", 2
Expected10
5
Input
"FF", -16
Expected-225
6
Input
"1010", 10
Expected1010
Focus radio
Paused · SomaFM · Fluid