How to remove specific element from an array using python

后端 未结 6 979
不知归路
不知归路 2020-12-12 17:57

I want to write something that removes a specific element from an array. I know that I have to for loop through the array to find the element that matches the c

6条回答
  •  醉话见心
    2020-12-12 18:12

    Using filter() and lambda would provide a neat and terse method of removing unwanted values:

    newEmails = list(filter(lambda x : x != 'something@something.com', emails))
    

    This does not modify emails. It creates the new list newEmails containing only elements for which the anonymous function returned True.

提交回复
热议问题