Can someone review the mistake of my substr checker for LUCKSTR

https://www.codechef.com/viewsolution/74024778

Above is my sumbission for problem:- CodeChef

I know that i can solve this question with C++ STL or python inbuilt functions for finding substr but can someone tell me what the problem with my own substring checking.