The function used to convert any Python object to a string is the str() function. This function takes an object as an argument and returns its string representation.
Example:
# Converting different types of objects to strings
number = 123
float_number = 45.67
boolean_value = True
list_value = [1, 2, 3]
# Using str() to convert to strings
string_number = str(number)
string_float = str(float_number)
string_boolean = str(boolean_value)
string_list = str(list_value)
print(string_number) # Output: '123'
print(string_float) # Output: '45.67'
print(string_boolean) # Output: 'True'
print(string_list) # Output: '[1, 2, 3]'
Summary:
Use the str() function to convert any Python object to its string representation.
