python make list string 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: how to make a list string in python

n = ["Hello"," I'm " , "12" , " Years Old "] # Our list
String = "" # Our string
for x in n :
    String += x
    
print(String) #Prints it

Example 3: python3 create list from string

input = ['word1, 23, 12','word2, 10, 19','word3, 11, 15']
output = []
for item in input:
    items = item.split(',')
    output.append([items[0], int(items[1]), int(items[2])])