Python for Beginners : List_Clarifications_1

 Removing all the occurrences of an element in a List

listname.remove(element) - removes an element from the given list. If an element occurs more than once in a list, the first occurrence of that element will be removed. 

To remove all the occurrences of an element from the given list, list comprehension technique can be used. By using this technique, all the other elements, except the given element, are moved to the same list.





Comments

Popular posts from this blog

வானாய் இரு