How to convert int to string in Python

We can convert an integer data type using the Python built-in str() function. This function takes any data type as an argument and converts it into a string. But we can also do it using the "%s" literal and using the .format() function. Below is the syntax of the str() function.

Syntax -

Let's understand the following example.

Example - 1 Using the str() function

Output:


25

25

Example - 2 Using the "%s" integer

Output:



Example - 3: Using the .format() function

Output:



Example - 4: Using f-string

Output:



We have defined all methods of converting the integer data type to the string type. You can use one of them according to your requirement.






Contact US

Email:[email protected]

How to convert int to string in Python
10/30