Problem je u tome što Python nema ugrađenu funkciju za uklanjanje više stringova sa liste.
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>)
Strings
U Pythonu su stringovi nizovi znakova. Stringovi se mogu koristiti za pohranjivanje teksta, brojeva ili bilo koje druge vrste podataka.
Da biste kreirali string u Pythonu, koristite konstruktor stringa:
string = “Zdravo”
Također možete kreirati niz spajanjem dva niza zajedno:
string = “Zdravo” + “Svijet”
liste
U Pythonu, liste su struktura podataka koja vam omogućava da pohranite kolekciju stavki. Liste mogu biti prazne ili mogu sadržavati bilo koju vrstu objekta, uključujući druge liste.
Da biste kreirali listu u Pythonu, koristite funkciju list(). Da biste pristupili prvoj stavci na listi, koristite funkciju index(). Da biste pristupili posljednjoj stavci na listi, koristite funkciju len().
Da biste dodali stavku na kraj liste, koristite funkciju append(). Da biste uklonili stavku sa kraja liste, koristite funkciju pop().