I want to compare the wordlist and the checklist by using map function and lambda function if the words in wordlist and checklist. this words will be deleted in wordlist. Anyone can help me? thanks a lot
wordlist = ['hello','world','Tom']
checklist = ['hello','world']
print('before')
print(wordlist)
list(map(lambda x: wordlist.remove(x) if x in checklist else None ,wordlist))
print('after')
print(wordlist)
Current Result: before ['hello', 'world', 'Tom'] after ['world', 'Tom']
Expected result: before ['hello', 'world', 'Tom'] after ['Tom']
Aucun commentaire:
Enregistrer un commentaire