How do I convert a list into a string with spaces in Python?

user1653402 picture user1653402 · Sep 7, 2012 · Viewed 146.2k times · Source

How can I convert a list into a space-separated string in Python?

For example, I want to convert this list:

my_list = [how,are,you]

Into the string "how are you"

The spaces are important. I don't want to get howareyou as I have with my attempt so far of using

"".join(my_list)

Answer

Joran Beasley picture Joran Beasley · Sep 7, 2012
" ".join(my_list)

you need to join with a space not an empty string ...