Degree of Profanity in a Sentence Given a comment or a sentence and a list of profane words, How do I write a program to print the degree of profanity in that sentence?
One way to approach it is to split the sentence into tokens and count the number of tokens that are profanities.

import re

def tokenize(text): 
    return re.findall(r'\w+', text.lower())

profane_tokens = {"nerfherder"}

sentence = "Why you stuck-up, half-witted, scruffy-looking nerfherder!"

tokens = tokenize(sentence)

# Rate: number of occurrences normalized by total number
degree_of_profanity = sum(1 for t in tokens if t in profane) / len(tokens)


This code will not handle multiple tokens and many profanities are multiple tokens.