私がリストを持っているとしましょう
x = [ 'apple', 'orange', 'grape','strawberry']
リストxの単語から文字「e」を削除するか、次のような新しいリストを返したい
['appl', 'orang', 'banana', 'grap', 'strawbrry']
私はこれを試しました:
for i in x:
for z in i:
if z == 'e':
i.remove(z)
そして、私が期待したエラーが発生しました: AttributeError: 'str' object has no attribute 'remove' だから、2 番目のループの前に list(i) を試しましたが、思い通りに動作しませんでした。