>>> import ast
>>> x = '[ "A","B","C" , " D"]'
>>> x = ast.literal_eval(x)
>>> x
['A', 'B', 'C', ' D']
>>> x = [n.strip() for n in x]
>>> x
['A', 'B', 'C', 'D']
# 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)
# Python program to convert a list
# to string using list comprehension
s = ['I', 'ate', 2, 'shake', 'and', 3, 'chocolates']
# using list comprehension
listToStr = ' '.join([str(element) for element in s])
print(listToStr)
https://mefiz.com/ # For Developer
import random
n = random.sample(range(1,51214), 5)
listToString = ''.join([str(elem) for elem in n])
print(n)
print(listToString)
using System;
using System.Collections.Generic;
public class Example
{
public static void Main()
{
List<string> list = new List<string>() { "A", "B", "C" };
char delim = ',';
string str = String.Join(delim, list);
Console.WriteLine(str);
}
}
/*
Output: A,B,C
*/