Python str() built-in function

From the Python 3 documentation

Return a string version of object. If object is not provided, returns the empty string. Otherwise, the behavior of str() depends on whether encoding or errors is given.

Introduction

The str() function in Python is a built-in function that returns a string version of an object. If no object is provided, it returns an empty string. It’s a versatile function for converting other data types to strings.

Examples

# transform an integer to a string
from_integer = str(29)
print(from_integer)
print(type(from_integer))
29
<class 'str'>
# transform a float to string
from_float = str(-3.14)
print(from_float)
print(type(from_float))
-3.14
<class 'str'>
# return an empty string
str()
''