私は基本的に、次のような文を含む文字列のリストを取得しようとしています:
sentence = ['Here is an example of what I am working with', 'But I need to change the format', 'to something more useable']
それを次のように変換します。
word_list = ['Here', 'is', 'an', 'example', 'of', 'what', 'I', 'am',
'working', 'with', 'But', 'I', 'need', 'to', 'change', 'the format',
'to', 'something', 'more', 'useable']
私はこれを使ってみました:
for item in sentence:
for word in item:
word_list.append(word)
各文字列を取り、その文字列の各項目を word_list に追加すると思いましたが、出力は次の行に沿ったものです。
word_list = ['H', 'e', 'r', 'e', ' ', 'i', 's' .....etc]
愚かな間違いを犯していることはわかっていますが、理由がわかりません。誰か助けてもらえますか?