list_a=[362,673,196,452,972]
I want to convert this list_a
into a string
Individually for each index of the list_a
I'm able to convert to string. For ex: list_a[0]=str(362)
but i want to convert the list at once.
list_a=[362,673,196,452,972]
I want to convert this list_a
into a string
Individually for each index of the list_a
I'm able to convert to string. For ex: list_a[0]=str(362)
but i want to convert the list at once.
Like Johnny mentions in his comment list comprehension is your friend.
list_a=[362,673,196,452,972]
list_b=[str(x) for x in list_a]
print(list_a)
# create new list of strings
print(list_b)
# join to a single string
print(','.join(list_b))
# or use print if you don't want a new list
print(*list_a,sep=',')
output:
[362, 673, 196, 452, 972]
['362', '673', '196', '452', '972']
362,673,196,452,972
362,673,196,452,972