Exercise 2 Advanced - Wrong answer error?July 14, 2021 at 6:43pm
Hi there, I was doing Exercise 2 in the advanced mode. I am pretty sure the output is the right one ( PAN NYC CAS AMS HEL 283.7 kg ), but the test button keeps saying it is wrong. Can anyone confirm if the result is the correct one?
July 20, 2021 at 7:44am
July 22, 2021 at 4:24pm
July 26, 2021 at 8:11pm
Hi (raulf), that's right. We have added a comment to the template code highlighting this fact now. Hopefully it doesn't cause confusion anymore. Sorry for the inconvenience it caused you!
The error occurs as the testing system in the backend calls the main method multiple times, which results in incorrect values of the global variable over subsequent function calls. Also, it's generally a good coding practice to keep code self-contained to prevent unintended consequences - like this one ;)