Python has an int() function that you’ve seen a bit of already. It can turn non-integer input into an integer, like this:

int("42") # ==> 42

What you might not know is that the int function actually has an optional second parameter.

int("110", 2) # ==> 6

When given a string containing a number and the base that number is in, the function will return the value of that number converted to base ten.



In the console are several different ways that you can use the int function’s second parameter.On line 7, use int to print the base 10 equivalent of the binary number 11001001.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?