My code is not passing one test case

the earlier TA was unable to solve my doubt
please ammend the given code