Can you please tell me why this code is not passing four test cases

can you please tell me why this code is not passing four test cases

Hello @KetanPandey,

I have corrected your code:

Refer to comments for better understanding.

Hope, this would help.
Give a like if you are satisfied.

thanku so much…

Hey @KetanPandey,

You replied thanku and then reopened the doubt.
Do you still have any doubts left?

oh,it was by mistake