turn list to string python code example
Example 1: how to convert list into string in python
list_of_num = [1, 2, 3, 4, 5]
# Covert list of integers to a string
full_str = ' '.join([str(elem) for elem in list_of_num])
print(full_str)
Example 2: list to string python
List = ["ITEM1", "ITEM2", "ITEM3"]
string_version = "".join(List)
print(string_version)
Example 3: how do i convert a list to a string in python
lines2 = " ".join(lines) # Converts the list to a string.
# This should work for writing to a file
file.write(lines2)
Example 4: 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 5: convert list to string python
>>> mylist = ['spam', 'ham', 'eggs']
>>> print ', '.join(mylist)
spam, ham, eggs
Example 6: how to convert a list to a string in python
array = []
STR = ''
for i in array:
STR = STR+i