문제

I apologize in advance if this question has already been asked and answered, but I cannot find an answer. I do not know the technical term for it so I will write the desired input and output. Basically I have a list of strings, each string containing a word. How would I make it so that the words just appear as they are, rather than a list of strings:

I have:

['hello','my','name','is','david']

But need:

hello my name is david

The purpose of this code is to write

hello my name is david

to a file, but i'm confident I can do that part myself.

If this has already been answered a link to the question would be great, thanks.

도움이 되었습니까?

해결책

You would join them together:

words = ['hello','my','name','is','david']
sentence = ' '.join(words)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top