Python Tutorial - While Loop - Guessing Game

  Рет қаралды 14,664

Geek Tutorials

Geek Tutorials

Күн бұрын

Пікірлер: 11
@applemilkshake7580
@applemilkshake7580 4 жыл бұрын
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.")
@farahmessan
@farahmessan 6 жыл бұрын
This was very helpful! But what if you want a specific number of trials to guess the answer
@GeekTutorials1
@GeekTutorials1 6 жыл бұрын
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.
@9464dhhudheub
@9464dhhudheub 3 жыл бұрын
Really helpful thanks
@wewergamer5485
@wewergamer5485 Жыл бұрын
I cant find why but the loop is infinity it isnt stop
@GeekTutorials1
@GeekTutorials1 Жыл бұрын
What's your code look like?
@wewergamer5485
@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
@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: "))
@michereff16
@michereff16 3 жыл бұрын
Thank you very much!!
@newstodayplus
@newstodayplus 2 жыл бұрын
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
@GeekTutorials1
@GeekTutorials1 2 жыл бұрын
That's a great idea
Python Tutorial - While Loop - Dice Game
12:17
Geek Tutorials
Рет қаралды 44 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
#20 Python Tutorial for Beginners | While Loop in Python
12:43
Telusko
Рет қаралды 1,6 МЛН
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 439 М.
Let's code a Python NUMBER GUESSING GAME! 🔢
8:20
Bro Code
Рет қаралды 12 М.
The Basics of while Loop in Python
8:17
Neso Academy
Рет қаралды 66 М.
Python Special Programs - Number Guessing Game
13:16
Neso Academy
Рет қаралды 11 М.
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 72 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 398 М.
Python For Loops - Python Tutorial for Absolute Beginners
14:42
Programming with Mosh
Рет қаралды 640 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН