I don't think we need to create a list in this comprehension:
|
count = len([word for word in words if word.lower() in swords]) |
Instead, I think we can just iterate over words and keep a count variable. For very large strings this would save the time and memory needed to alloc the list.