Code checking not all test cases are getting passed

what is the problem with my logic building as some test cases are still not getting passed