Build a Number Guessing Game

Hello, I have tested this challenge in my terminal and it works correctly. But, the test scripts fail with inconsistent results. Everytime it is run, a combination of tests from test #8 to test#13 fail. Test#8 fails consistently while test#9 passes sometimes and fails sometimes. Again tests# 10, 11 and 12 have passed sometimes - all of this with the same code. Here are screen shots of the code and the results -

Can anyone please help me understand what is wrong here.
Thanks.

Could you share your script and the database dump?

Here is the link to my script and database - GitHub - rsnarasimha/Number-Guess.

Try removing all printed lines that are not required. Tests are checking number of guesses and secret number in a very peculiar way, which can sometimes give different results than the actual numbers.

Hello, I did try that, but that did not help. Finally, I restructured my code as part of a function call and somehow this helped pass all the tests…

So all my code went into function PLAY_GAME() and then a call to PLAY_GAME seems to have fixed the problem.