StringJoin with Spaces
In M10.1+ you can use StringRiffle
:
StringRiffle[
{"hi","how","are","you"},
" "
] //InputForm
"hi how are you"
Another option is to use ListFormat
TextString[list, ListFormat -> {"", " ", ""}]
gives
"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"