I liked this tutorial a lot. Summary of what I learned: In the while loop, we have to repeat the (variable and value) above the while condition to prompt input again so it can keep asking for correct input. When the while condition is proven false (finally!), it leaves the while loop and moves on to the next line in the code. Print("Bob wants you to find the right number so you can leave the dungeon." X=random.randrange(1,100000000000) Guess = int(input("enter num: ") While Guess!= X: print("Bob spins the dungeon lock once more. You're not getting out.") Guess = int(input( "enter num:") #without this or would never prompt you again. print ("Bob begrudgingly let's you or of the dungeon. You must be using witchcraft to guess so high. Back in the dungeon you go.")
@farahmessan6 жыл бұрын
This was very helpful! But what if you want a specific number of trials to guess the answer
@GeekTutorials16 жыл бұрын
Good question. You'll probably want a variable that tracks the number of guesses a user makes. Once that variable hits 0, then it's game over.
@9464dhhudheub3 жыл бұрын
Really helpful thanks
@wewergamer5485 Жыл бұрын
I cant find why but the loop is infinity it isnt stop
@GeekTutorials1 Жыл бұрын
What's your code look like?
@wewergamer5485 Жыл бұрын
@@GeekTutorials1 import random x = random.randrange(1,10) guess = int(input("Guess a number between 1 to 10: ")) while guess != x: print("Wrong number, try again") guess = ("Guess a number between 1 to 10: ") print("Correct! You guessed the number!!!")
@gl.7949 Жыл бұрын
@@wewergamer5485 You need to change this part: while guess != x: print("Wrong number, try again") guess = ("Guess a number between 1 to 10: ") Into this: while guess != x: print("Wrong number, try again") guess = int(input("Guess a number between 1 to 10: "))
@michereff163 жыл бұрын
Thank you very much!!
@newstodayplus2 жыл бұрын
I could make the guess the number but then I wanted to add scores -1 incorrect +3 correct 0 you lose 100 you win And user starts with 10 points