Sir can't get why its failing in other test cases

sir, it’s working fine for the first test case but can’t know why its not working on other test cases it would be nice if you would be telling the error in my approach rather than giving the code for this problem. below I have attached the code.
Thanks :slight_smile:

sry i got the error which i was facing in this code