Sorun, Python'un bir listeden birden çok dizeyi kaldırmak için yerleşik bir işlevi olmamasıdır.
I have a list of strings: <code>list = ['a','b','c','d'] </code> and I want to remove multiple strings from the list, for example: <code>remove_list = ['a', 'c'] </code> A: You can use <code>set.difference()</code>: (If you don't mind the order of elements in your list) (If you want to keep the order of elements in your list, then use <code>filter()</code>) (If you want to keep only unique elements in your list, then use <code>set()</code>) (If you want to remove all duplicates from your list, then use <code>list(set())</code>) (If you want to remove all duplicates from your list and keep the order of elements as well, then use <code>[i for i in set(lst)]</code>)
Ekstra Tel
Python'da, dizeler karakter dizileridir. Dizeler, metni, sayıları veya diğer herhangi bir veri türünü depolamak için kullanılabilir.
Python'da bir dize oluşturmak için dize yapıcısını kullanırsınız:
dize = “Merhaba”
İki diziyi birleştirerek de bir dizi oluşturabilirsiniz:
string = “Merhaba” + “Dünya”
Listeler
Python'da listeler, bir öğe koleksiyonunu depolamanıza izin veren bir veri yapısıdır. Listeler boş olabilir veya diğer listeler dahil olmak üzere herhangi bir türde nesne içerebilir.
Python'da bir liste oluşturmak için list() işlevini kullanırsınız. Bir listedeki ilk öğeye erişmek için index() işlevini kullanırsınız. Bir listedeki son öğeye erişmek için len() işlevini kullanırsınız.
Bir listenin sonuna bir öğe eklemek için append() işlevini kullanırsınız. Bir listenin sonundan bir öğeyi kaldırmak için pop() işlevini kullanırsınız.