The following is a method to share with you a python list to delete all specified elements. It has a good reference value and I hope it will be helpful to everyone. Come and take a look together
As shown below:
a = [1,1,1,2,3,45,1,2,1] a.remove(1) result: [1,1,2,3,45,1,2,1] while 1 in a: a.remove(1) result: [2,3,45,2]
Related recommendations:
How to delete files and directories in python
Detailed description of Python list sorting methods reverse, sort, sorted
The above is the detailed content of Python list removes all specified elements. For more information, please follow other related articles on the PHP Chinese website!