Removing a string from a list

后端 未结 4 845
抹茶落季
抹茶落季 2021-01-16 04:04

I create a list, and I want to remove a string from it.

Ex:

>>> myList = [\'a\', \'b\', \'c\', \'d\']   
>>> myList = myList.remove         


        
4条回答
  •  深忆病人
    2021-01-16 04:35

    Just an addition to Anand's Answer,

    mylist = mylist.remove('c')
    

    The above code will return 'none' as the return type for my list. So you want to keep it as

    mylist.remove('c')
    

提交回复
热议问题