Two of the test cases showing wrong answer in chewbacca and number

This is the link to my code for the same problem while last three cases are being satisfied the first two aren’t and even after a long session of brainstorming I am unable to get through. Please point the error.