How to Convert a Python Integer to String?
In Python, you can convert an integer to a string using the str()
function. Here's an example:
number = 123
string = str(number)
print(type(number)) # Output: <class 'int'>
print(type(string)) # Output: <class 'str'>
In this example, the str()
function is used to convert the number
variable (which contains an integer value) to a string. The resulting string is stored in the string
variable.
The print()
function is used to display the type of the number
and string
variables. As you can see, the number
variable is of type int
and the string
variable is of type str
.