I am trying to count the number of count of occurrence of each word in a text, I have below code but it seems that it is not jumping to the else part of my loop
text = "Joy is joy but joy is not finding a solution"
x= {}
for mot in text.lower().split():
if x.get(mot) not in x.keys():
print(mot)
x[mot] = 1
print(x[mot])
else :
print("the word is" + mot)
x[mot] = (x[mot]+1)
print((x[mot]))
print(x)
x
Any help appreciated to resolve it with an if loop