How to convert an integer to a string in Python
Python has a built-in function str() which converts the passed argument into a string format.
1 of 3
The str() function returns a string version of an object. The object can be int, char, or a string. If the object is not passed as an argument, then it returns an empty string.
Syntax
str(object, encoding=encoding, errors=errors)
Example
The following code converts an integer to a string and appends it to the other string.
# An integer version of yearinteger_year = 2019# A string version of yearstring_year = str(2019)# Concatinates the string with the string version of yearprint("This is " + string_year + ".")# Returns none if no argument is providedprint(str())
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved