Bizarre error message when running test (Information gain)

Hi all,
I passed the tests of exercises 1 & 2, but I receive bizarre error messages when running the test for exercise 3 (compute information gain). I’ve implemented the hints to no avail. No typos. The information gain from the code = the expected output, and the tests should pass. Can somebody please advise?
Much appreciated,

The challenge with defining variables inside an if statement is that if the clause isn’t executed, you can end up with an undefined variable.

Thanks! I’ll have a look into this. Much appreciated TMosh