A list can be converted to a string using the str()
function.
In this blog post, you will learn how to use str()
function to convert python list to string.
Step 1: Create a list
my_list = [1, 2, 3, 4, 5]
Step 2: Convert list to string
s_list = str(my_list)
Step 3: Print the string and type
print(s_list) print(type(s_list))
Output:
[1, 2, 3, 4, 5]
<class 'str'>