Here is my code, I'm trying to scan user's input against Json file that contains a wordlist of negative words in order to get the sum of negative words in a user's input.
Note: I take the user input in a list.
current Output: No output that relates to the code below is printed.
def SumOfNegWords(wordsInTweet):
f = open ('wordList.json')
wordList = json.load(f)
NegAmount = 0
for words in wordsInTweet: #for words in the input
if wordsInTweet in wordList['negative']:
NegAmount += 1
print("The Sum of Negative Words =", NegAmount)
else: print("No negative words found")
source https://stackoverflow.com/questions/70488967/python-if-statement-inside-a-for-loop-checking-on-a-json-file
Comments
Post a Comment