How to receive message from each execute code in while loop by condition will give to it

How to add message to each condition we give to while loop.
Sometime like this

secret_number = 9
guess_count = 0
guess_limit = 3
While guess_count < guess_limit:
guess = input ("Guess: ")
guess_count += 1
if guess == guess_number:
print (“You won”)
break
else:
print (“You failed”)

Now, what if user type wrong guess for the first guess and I want the terminal to print message like this “Sorry, you failed but you still have two chances”

And the user failed second chance again and I want the terminal to print message to user like this “Sorry, you failed your second chance but you still have your last chance”

Please guys, how to do that.

Hi! There is more than one way, but here is how the code should look like to do what you want:

secret_number = 9
guess_count = 0
guess_limit = 3

while guess_count < guess_limit:
	guess = input("Guess: ")
	guess_count += 1
	if guess == secret_number:
		print("You won")
		break
	elif guess != secret_number and guess_count == 1:
		print("Sorry, you failed but you still have two chances")
	elif guess != secret_number and guess_count == 2:
		print("Sorry, you failed your second chance but you still have your last chance")
	else:
		print ("You failed")

Hope this helps :slight_smile:

Hey bro, can we exchange numbers?

Sorry, no numbers, but I can give you my email if you want.

Okay bro, but I like using Whatsapp bro

Are you there, brother

Only email: elenerka@wp.pl

Thank you very much, brother