Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#Code for checking if word is swear word
def readSwearWords(): #Reads banned words from bannedWords.txt
swearWords = []
with open('bannedWords.txt', 'r') as reader:
for word in reader:
swearWords.append((word.strip()))
return swearWords
def isSwearWord(userInput):
wordCondition = False
userInput = userInput.lower()
for curseWord in readSwearWords():
curseWord = curseWord.lower()
if (' ' + curseWord + ' ') in (' ' + userInput + ' '): #For checking if swear word which contains 2 or more words is in user input
wordCondition = True
return wordCondition