In Python an integer can be converted into a string using the built-in str() function. The str() function takes in any python data type and converts it into a string. But use of the str() is not the only way to do so. This type of conversion can also be done using the "%s" keyword, the .format function or using f-string function.
Below is the list of possible ways to convert an integer to string in python:
1. Using str() function
Syntax: str(integer_value)
Example:
num = 10 # check and print type of num variable print(type(num)) # convert the num into string converted_num = str(num) # check and print type converted_num variable print(type(converted_num)) |
2. Using “%s” keyword
Syntax: “%s” % integer
Example:
num = 10 # check and print type of num variable print(type(num)) # convert the num into string and print "% s" % num |
3. Using .format() function
Syntax: ‘{}’.format(integer)
Example:
num = 10 # check and print type of num variable print(type(num)) # convert the num into string and print "{}".format(num) |
4. Using f-string
Syntax: f'{integer}’
Example:
num = 10 # check and print type of num variable print(type(num)) # convert the num into string converted_num = f'{num}' # print type of converted_num print(type(converted_num)) |
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Python | Convert list of string into sorted list of integer
- Python Program to convert List of Integer to List of String
- Python - Convert Alternate String Character to Integer
- Python - Convert Tuple String to Integer Tuple
- Convert string to integer in Python
- How to convert string to integer in Python?
- Python - Convert Integer Matrix to String Matrix
- How to Convert String to Integer in Pandas DataFrame?
- Python | Convert a list of multiple integers into a single integer
- Python | Ways to convert Boolean values to integer
- Python | Convert Tuple to integer
- Python - Convert Binary tuple to Integer
- Different Ways to Convert Double to Integer in C#
- How to Convert Integer to Datetime in Pandas DataFrame?
- Convert IP address to integer and vice versa
- Python | Convert List of String List to String List
- Python | Multiply Integer in Mixed List of string and numbers
- Python - String Integer Product
- Python - Sort String by Custom Integer Substrings
- Python - Integers String to Integer List
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.

