Answers for "remove from list if not maches in list"

0

remove from list if not maches in list

>>sents = ['@$\tthis sentences needs to be removed', 'this doesnt',
     '@$\tthis sentences also needs to be removed',
     '@$\tthis sentences must be removed', 'this shouldnt',
     '# this needs to be removed', 'this isnt',
     '# this must', 'this musnt']
>>>[x for x in sents if not x.startswith('@$\t') and not x.startswith('#')]
['this doesnt', 'this shouldnt', 'this isnt', 'this musnt']
Posted by: Guest on October-07-2020

Python Answers by Framework

Browse Popular Code Answers by Language