Yahoo Αναζήτηση Διαδυκτίου

Αποτελέσματα Αναζήτησης

  1. 4 Φεβ 2012 · You could use a list comprehension: thelist = [item for item in thelist if item.attribute != somevalue] This will remove all items with item.attribute == somevalue. If you wish to remove just one such item, then use WolframH's solution.

  2. 17 Μαρ 2020 · I want to create a method inside to delete a list item by code attribute. class MyClass(Base): def __init__(self, code, name): self.__code = code self.__name = name @property def code(self): return self.__code @property def name(self): return self.__name @code.setter def code(self, new_code): self.__code=new_code def __repr__(self): x = f"Code ...

  3. 21 Δεκ 2023 · The list remove () function in Python removes the first occurrence of a given item from the list. It make changes to the current list. It only takes one argument that is the element you want to remove and if that element is not present in the list, it gives ValueError.

  4. 24 Ιουν 2024 · Remove or clear all items from a Python list. To remove all items from a list, use the clear() method: >>> my_list = [1, 2, 3] >>> my_list.clear() >>> my_list [] Remove duplicates from a list. There is no special function or method to remove duplicates from a list, but there are multiple tricks that we can use to do so anyway.

  5. The remove() method removes the first matching element (which is passed as an argument) from the list. Example # create a list prime_numbers = [2, 3, 5, 7, 9, 11]

  6. 2 Μαρ 2022 · How to Remove an Element from a List Using the remove() Method in Python . To remove an element from a list using the remove() method, specify the value of that element and pass it as an argument to the method. remove() will search the list to find it and remove it.

  7. 17 Αυγ 2023 · In Python, you can remove items (elements) from a list using the clear(), pop(), and remove() methods. It is also possible to delete items using the del statement by specifying a position or range with an index or slice.

  1. Γίνεται επίσης αναζήτηση για