Ask coding questions

← Back to all posts
I'm a bit confused, could use some help!
ItsArthurisk (0)

Down below, you will see code for a number guessing game that gives you ten turns to guess a number from 1 - 100.

The problem here is that I want to make a turn counter that will make the user lose as soon as he reaches the 10th turn.

So please help and sauce me recommendations, tips and also lines of code that I can drag and drop in to my code.

https://repl.it/@ItsArthurisk/NumGuess

-Harry

Commentshotnewtop
Steven_The_GuyT (203)

you could use a for loop to fix it I think:

for i in range(0,10):
  if (userguess<randnum):
    print('Too Low!')
  #and then do the other stuff

Also, you made an error in line 16. The exclamation point in python means not, so what you're saying is basically:

while userguess is not equal to randnum:
<do something>