input : my_list = [1,2,3] output : 1,2,3
How to convert?
input : my_list = [1,2,3] output : 1,2,3
How to convert?
Please mention which language
const my_list = [1,2,3]
console.log(my_list.join()); -> this one will return 1,2,3 string
Code:
my_list = [1,2,3]
ints = [int(item) for item in my_list]
print(ints)
Looking at your expected output, did you intend to convert the list to a comma separated string? Is it in Javascript? Python? Haskell?
Already answered for javascript here and python here and Haskell here.
For Javascript using the join method.
const elements = [1, 2, 3];
console.log(elements.join());
// expected output: "1,2,3"
console.log(elements.join(''));
// expected output: "123"
console.log(elements.join('-'));
// expected output: "1-2-3"