# Python program to convert any base to decimal by using int() method

Given a number and its base, the task is to convert the given number into its corresponding decimal number. The base of number can be anything like digits between 0 to 9 and A to Z. Where the value of A is 10, value of B is 11, value of C is 12 and so on.

Examples:

```Input : '1011'
base = 2
Output : 11

Input : '1A'
base = 16
Output : 26

Input : '12345'
base = 8
Output : 5349
```

Approach –

• Given number in string form and base
• Now call the builtin function int(‘number’, base) by passing the two parameters any base number in String form and base of that number and store the value in temp
• Print the value temp

## Python3

 `# Python program to convert any base ` `# number to its corresponding decimal ` `# number ` ` `  `# Function to convert any base number ` `# to its corresponding decimal number ` `def` `any_base_to_decimal(number, base): ` `     `  `    ``# calling the builtin function  ` `    ``# int(number, base) by passing  ` `    ``# two arguments in it number in ` `    ``# string form and base and store ` `    ``# the output value in temp ` `    ``temp ``=` `int``(number, base) ` `     `  `    ``# printing the corresponding decimal ` `    ``# number ` `    ``print``(temp) ` ` `  `# Driver's Code ` `if` `__name__ ``=``=` `'__main__'` `: ` `    ``hexadecimal_number ``=` `'1A'` `    ``base ``=` `16` `    ``any_base_to_decimal(hexadecimal_number, base)`

Output:

`26`
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Improved By : Akanksha_Rai

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.