python make list of strings code example
Example 1: python convert list of lists to list of strings
['delim'.join([str(elem) for elem in sublist]) for sublist in my_list]
my_list = [[1, '1', 1], [2,'2',2], [3,'3',3]]
[' '.join([str(elem) for elem in sublist]) for sublist in my_list]
--> ['1 1 1', '2 2 2', '3 3 3']
my_list = [[1, '1', 1], [2,'2',2], [3,'3',3]]
['_'.join([str(elem) for elem in sublist]) for sublist in my_list]
--> ['1_1_1', '2_2_2', '3_3_3']
Example 2: how to make a list string in python
n = ["Hello"," I'm " , "12" , " Years Old "]
String = ""
for x in n :
String += x
print(String)
Example 3: python convert list to list of strings
lsit_of_strings = [str(i) for i in your_list]
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']
Example 4: python list of list to list of string
list_of_string = [''.join(element) for element in list_of_list]