<gh_stars>0
import re

def solution(paragraph, banned):
    # preprocessing / ^ meaning not, w meaning word character
    w = [w for w in re.sub(r'[^\w]',' ', paragraph).lower().split() if w not in banned]

    d = {}

    for _w in w:
        cnt = 1
        if _w not in d:
            d[_w] = cnt
        else:
            cnt = d[_w]+1
            d[_w] = cnt

    return max(d, key=d.get)

paragraph = "Bob hit a ball, the hit BALL flew far after it was hit."
banned = ["hit"]
# Output: "ball"

solution(paragraph, banned)
import re

def solution(paragraph, banned):
    # preprocessing / ^ meaning not, w meaning word character
    w = [w for w in re.sub(r'[^\w]',' ', paragraph).lower().split() if w not in banned]

    d = {}

    for _w in w:
        cnt = 1
        if _w not in d:
            d[_w] = cnt
        else:
            cnt = d[_w]+1
            d[_w] = cnt

    return max(d, key=d.get)

paragraph = "Bob hit a ball, the hit BALL flew far after it was hit."
banned = ["hit"]
# Output: "ball"

solution(paragraph, banned)
# preprocessing / ^ meaning not, w meaning word character # Output: "ball"