ManyPets interview question

fix the bug in this code only editing 2 lines