How to find the int value of a string in Python? Last Updated : 01 Aug, 2020 Comments Improve Suggest changes 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 How to Substring a String in Python A String is a collection of characters arranged in a particular order. A portion of a string is known as a substring. For instance, suppose we have the string "GeeksForGeeks". In that case, some of its substrings are "Geeks", "For", "eeks", and so on. This article will discuss how to substring a str 4 min read Convert String to Int in Python In Python, converting a string to an integer is important for performing mathematical operations, processing user input and efficiently handling data. This article will explore different ways to perform this conversion, including error handling and other method to validate input string during conver 3 min read Convert Hex String To Integer in Python Hexadecimal representation is commonly used in computer science and programming, especially when dealing with low-level operations or data encoding. In Python, converting a hex string to an integer is a frequent operation, and developers have multiple approaches at their disposal to achieve this tas 2 min read Convert integer to string in Python In this article, weâll explore different methods for converting an integer to a string in Python. The most straightforward approach is using the str() function.Using str() Functionstr() function is the simplest and most commonly used method to convert an integer to a string.Pythonn = 42 s = str(n) p 2 min read Convert String to Long in Python Python defines type conversion functions to directly convert one data type to another. This article is aimed at providing information about converting a string to long. Converting String to long A long is an integer type value that has unlimited length. By converting a string into long we are transl 1 min read Like