The str function
The str function creates a new string from the original object. In the first parameter, we specify the object from which we will make a string. In the second optional parameter, you can specify the encoding (by default, UTF-8), and in the third optional parameter, the error type in case of failure to convert to a string.
Syntax
str(the object from which we make a string, [encoding type], [error type])
Example
Let's use the str function to make a string from a number:
num = 1234
txt = str(num)
print(txt)
Result of code execution:
'1234'