How do I convert a list into a string with spaces in Python?
For Non String list
we can do like this as well
" ".join(map(str, my_list))
" ".join(my_list)
You need to join with a space, not an empty string.
I'll throw this in as an alternative just for the heck of it, even though it's pretty much useless when compared to " ".join(my_list)
for strings. For non-strings (such as an array of ints) this may be better:
" ".join(str(item) for item in my_list)