リスト内の文字列アイテムを単一の文字列に連結する簡単な方法はありますか?この機能は使えstr.join()
ますか?
たとえば、これは入力['this','is','a','sentence']
であり、これは目的の出力ですthis-is-a-sentence
sentence = ['this','is','a','sentence']
sent_str = ""
for i in sentence:
sent_str += str(i) + "-"
sent_str = sent_str[:-1]
print sent_str