How to find the int value of a string in Python? Last Updated : 01 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In Python, we can represent an integer value in the form of string. Int value of a string can be obtained by using inbuilt function in python called as int(). Here we can pass string as argument to this function which returns int value of a string. int() Syntax : int(string, base) Parameters : string : consists of 1's and 0's base : (integer value) base of the number. Returns : an integer value, which is equivalent of binary string in the given base. TypeError : Returns TypeError when any data type other than string or integer is passed in its equivalent position. By default, int() assumes the number to be in decimal notation. If we want a string representation of int which belongs to other number systems like binary, hexadecimal, octal. We need to pass an extra argument to this function specifying the base value. The base values are : binary : 2 octal : 8 hexadecimal : 16 Examples : Input : "A" (for base 16) Output : 10 Input : "510" Output : 510 Python3 1== # using base 16 s1 = "A" print(int(s1, 16)) # using the default base s2 = "510" print(int(s2)) Output : 10 510 Comment More infoAdvertise with us Next Article How to find the int value of a string in Python? R revathiugudi Follow Improve Article Tags : Python Python-Built-in-functions python-basics Practice Tags : python Similar Reads How to convert string to integer in Python? In Python, a string can be converted into an integer using the following methods : Method 1: Using built-in int() function: If your string contains a decimal integer and you wish to convert it into an int, in that case, pass your string to int() function and it will convert your string into an equiv 3 min read String to Int and Int to String in Python Python defines type conversion functions to directly convert one data type to another. This article is aimed at providing the information about converting a string to int and int to string. Converting a string to an int If we want to convert a number that is represented in the string to int, we have 2 min read How to Index and Slice Strings in Python? In Python, indexing and slicing are techniques used to access specific characters or parts of a string. Indexing means referring to an element of an iterable by its position whereas slicing is a feature that enables accessing parts of the sequence.Table of ContentIndexing Strings in PythonAccessing 2 min read How to find the factorial os a number using SciPy in Python? SciPy is an open-source Python library used to solve scientific and mathematical problems. It is built on NumPy and it allows us to manipulate and visualizing with a wide range of high-level commands. Scipy also provides a scipy.special.factorial() function to calculate factorial of any number. scip 2 min read How to Check the Type of an Object in Python In this article, we will explore the essential skill of determining the type of an object in Python. Before engaging in any operations on an object within the Python programming language, it is imperative to possess the knowledge of how to check its type. This fundamental task is encountered regular 4 min read Like