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 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