Is there a better way to filter text?
02:06 11 Aug 2026

I just made this peice of code that filters for bad words

# Saves forbidden words

forbidden_words = ("shit", "fuck", "ass", "bitch")

query = input()

query = query.lower()

# Analysis

if any(word in query for word in forbidden_words):

    print(query, "is not allowed!")

else:

    print(query, "is allowed")
python substring