Konversi semua item dalam daftar ke string python
mylist = [str(i) for i in mylist]
Hurt Hare
mylist = [str(i) for i in mylist]
# Python program to convert a list
# to string using list comprehension
s = ['I', 'want', 4, 'apples', 'and', 18, 'bananas']
# using list comprehension
listToStr = ' '.join([str(elem) for elem in s])
print(listToStr)
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)
map(str, mylist)
#python 3+ map( ) doesn't output a list, which is why:
list(map(str, mylist)
#change 'str' to 'float' or 'int' for other outcomes
lines2 = " ".join(lines) # Converts the list to a string.
# This should work for writing to a file
file.write(lines2)