Relative Content

Tag Archive for pythonwhile-loop

Why is this while loop terminating midway?

I am running a while loop for a ‘guess the random number’ project. My problem is that when the user is finally guessing the right answer, the code below is not printing ‘Bingo’ as it should. Instead, it is exiting the while loop.

Why is this while loop terminating midway?

I am running a while loop for a ‘guess the random number’ project. My problem is that when the user is finally guessing the right answer, the code below is not printing ‘Bingo’ as it should. Instead, it is exiting the while loop.

I am trying to filter a while loop statement, and believe I do not fully understand something and trying to find a helpful way to make it more elegant

I am making a simple game with python on my own to test the little knowledge I have. Am trying to make a battleship style game, where users choose where they put their battleship and play against a computer, and am trying to filter the input of their response, have tried to make simple if x not in and/or statements to filter responses and the one I have found seems to be bad, just because it doesn’t feel right, would appreciate some helpful criticism and help to see if I could do this part better. I am trying to get the user to input the position of where they want to put their battleship set in how the game coordinate 1a, 2a, 1b, 2b, etc… and then trying to filter out their response so it only allows the code block to continue past this if they enter correctly. I know I could set a long list with all the proper answers in a single list, but if I were to make this game like a 10 by 10 grid there’d be a hundred things, and I feel this is the most simple solution I can find, but I’d just like some helpful criticism.