Python has a built-in function str()
which converts the passed argument into a string format.
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.
str(object, encoding=encoding, errors=errors)
The following code converts an integer to a string and appends it to the other string.
# An integer version of year integer_year = 2019 # A string version of year string_year = str(2019) # Concatinates the string with the string version of year print("This is " + string_year + ".") # Returns none if no argument is provided print(str())
RELATED TAGS
View all Courses