Hi all
I'm new to Python and working through some tutorials from my books.
I'm trying to write a simple program which the user has to guess a number, and it will say if they are to high or to low. I would like the program to stop after the user has had say 4 guesses and not allow them to guess anymore. I have tried to do this but when they get to 4 shots, it still lets them continue...anyone please give me some pointers?
Thank You.
My code is below.
number = 50
guess = 0
shots = 0
while guess != number:
shots=shots + 1
guess = input("Guess a Number ")
if shots == 4:
print "Guesses Over, you've had 4 shots"
elif guess > number:
print "Too High"
elif guess < number:
print "Too Low"
print "You guessed Correctly!
I'm new to Python and working through some tutorials from my books.
I'm trying to write a simple program which the user has to guess a number, and it will say if they are to high or to low. I would like the program to stop after the user has had say 4 guesses and not allow them to guess anymore. I have tried to do this but when they get to 4 shots, it still lets them continue...anyone please give me some pointers?
Thank You.
My code is below.
number = 50
guess = 0
shots = 0
while guess != number:
shots=shots + 1
guess = input("Guess a Number ")
if shots == 4:
print "Guesses Over, you've had 4 shots"
elif guess > number:
print "Too High"
elif guess < number:
print "Too Low"
print "You guessed Correctly!