Answer:
“count” method is absoloutly perfect to count this hing but your logics are not right in the programm.
So write your code as:
test = "If you do not do this you have to do this again"
print(test.count("If", 0, 100))
print(test.count("you", 0, 100))
print(test.count("do", 0, 100))
print(test.count("not", 0, 100))
print(test.count("this", 0, 100))
print(test.count("have", 0, 100))
print(test.count("to", 0, 100))
print(test.count("again", 0, 100))
The given codes output will be:
1
2
3
1
2
1
1
1
Hope you understand the thing and it helps you.
Happy coding.