Convert list elements to string Python code example

Example 1: list to string python

List = ["ITEM1", "ITEM2", "ITEM3"]
string_version = "".join(List)

print(string_version)

Example 2: python list to string

mystring = 'hello, world'

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

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

Example 3: convert list to string python

>>> mylist = ['spam', 'ham', 'eggs']
>>> print ', '.join(mylist)
spam, ham, eggs

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

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

Tags:

C Example