230k views
3 votes
How to limit the number of guesses in python

User Shadowtrot
by
5.2k points

1 Answer

5 votes

I thinkkkkk this is kind of what you are looking for?

while user != the_number:

...

if count == 5:

print("etc etc")

break

else:

print("You guessed it!!, the number is", the_number, "and it only"\

" took you", count , "tries")

Basically if you have 5 guesses it'll break it and stop the guesses

User MrAndre
by
4.6k points