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