I'm having some trouble using StringJoin --- the problem is that the StringJoin function creates a string where all the words in a list are combined without any spaces (whitespace)

For instance, list = {"hi","how","are","you"} StringJoin[list] will give me hihowareyou What do I have to do to get hi how are you as one string?


3 Answers 3


Another option is to use ListFormat

  TextString[list, ListFormat -> {"", "    ", ""}]


   "hi    how    are    you"
  • $\begingroup$ Thank you for this! All of the answers here worked but I found this to be the simplest $\endgroup$ Commented Oct 13, 2017 at 16:33

In M10.1+ you can use StringRiffle:

    " "
] //InputForm

"hi how are you"


The Map function will "do the same thing" to every element in a list. So we use that to StringJoin a space onto the end of every word in your list, except the last word. And then we Use StringJoin on that plus the last word in your list to put all those together into a single string. So

list = {"hi", "how", "are", "you"};
StringJoin[Map[StringJoin[#, " "]&, Most[list]], Last[list]]

which gives you the string "hi how are you"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.