how to turn list into string python code example

Example 1: list to string python

list1 = [1, 2, 3]
str1 = ''.join(str(e) for e in list1)

Example 2: list to string python

>>> L = [1,2,3]       
>>> " ".join(str(x) for x in L)
'1 2 3'

Example 3: python array to string

mystring = 'hello, world'

myarray = string1.split(', ') #output => [hello, world]

myjoin1 = ', '.join(myarray) #output => hello, world
myjoin2 = ' '.join(myarray) #output => hello world
myjoin3 = ','.join(myarray) #output => hello,world

Example 4: python convert list to list of strings

# Basic syntax using list comprehension:
lsit_of_strings = [str(i) for i in your_list]

# Example usage:
your_list = ['strings', 'and', 'numbers', 11, 23, 42]
lsit_of_strings = [str(i) for i in your_list]
print(lsit_of_strings)
--> ['strings', 'and', 'numbers', '11', '23', '42'] # List of strings

Example 5: how to convert a list to a string in python

array = []
STR = ''
for i in array:
    STR = STR+i