Python でリストから削除する場合、RemoveはあるけどRemoveAllは存在しないので、内包表記でフィルターをかける
# リスト samplelist = ['apple', 'strawberry', 'apple', 'lemon', 'apple', 'peach'] # apple ではないもの samplelist = [s for s in samplelist if s != 'apple'] # 結果 ['strawberry', 'lemon', 'peach'] print(samplelist)
