You Win!
Celebrate a correct guess.
You Win! is a free Coding for Kids lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Time to Celebrate! 🏆
Hi champion maker! 🏆 The best part of a game is WINNING! When the player guesses right, we throw a party with our words! 🎉
Let's learn to celebrate in style!
print('🎉 YOU WIN! 🎉')A Big Win Message 🎊
When the guess equals the secret, we show a HAPPY message! Use lots of emojis to make it exciting! 🎊
guess = 5
secret = 5
if guess == secret:
print('🎉🎉 CORRECT! You are a star! 🌟🎉🎉')Stop After Winning 🛑
Once you win, the game should STOP asking! The word break jumps out of the loop right away. 🛑
for tries in range(5):
print('Try', tries + 1)
if tries == 2:
print('Found it! Stopping! 🛑')
breakBreak When You Win 🏁
Let's use break to end the game the moment the player guesses correctly! 🏁 No need to keep asking!
secret = 3
for tries in range(5):
guess = int(input('Guess 1-5: '))
if guess == secret:
print('You win! 🏆')
break
else:
print('Try again! 🔁')Count the Tries 🔢
Let's tell the winner how many tries it took! We can show tries + 1 when they win. 🔢
secret = 3
for tries in range(5):
guess = int(input('Guess 1-5: '))
if guess == secret:
print('You won in', tries + 1, 'tries! 🏆')
breakWhat if They Don't Win? 😅
If the player uses all tries without winning, we kindly tell them the secret! We can use a special else after the loop. 😅
secret = 3
for tries in range(2):
guess = int(input('Guess 1-5: '))
if guess == secret:
print('You win! 🏆')
break
else:
print('Out of tries! The number was', secret, '😅')Win With Hints! 💡
Let's combine hints AND winning! Hints guide the player, and break celebrates the win. 💡🏆
secret = 7
for tries in range(4):
guess = int(input('Guess 1-10: '))
if guess == secret:
print('🎉 You got it! 🎉')
break
elif guess > secret:
print('Lower! 📉')
else:
print('Higher! 📈')A Trophy of Stars 🏅
Make the win SUPER special with a star border! Use '*' * 15 to repeat the star 15 times! 🏅
print('*' * 15)
print(' YOU WIN! 🏆')
print('*' * 15)The Complete Game! 🎮
Here is the WHOLE Guess the Number game! Random secret, hints, tries, winning, and a kind message if they run out. 🎮
import random
secret = random.randint(1, 20)
for tries in range(5):
guess = int(input('Guess 1-20: '))
if guess == secret:
print('🎉 You won in', tries + 1, 'tries! 🏆')
break
elif guess > secret:
print('Too high! 📉')
else:
print('Too low! 📈')
else:
print('The number was', secret, '! Play again? 🔁')Cheer the Player On 📣
Always make winning feel AMAZING! Add cheers, emojis, and kind words. Happy players play again! 📣
print('🌟 WOW! You are a guessing genius! 🌟')
print('Great job, superstar! 🎉')Game Maker Pro! 🚀
You built a complete game from start to finish! 🚀 You can make secret numbers, ask guesses, give hints, and celebrate wins. Amazing work!
tries = 3
print('You won in', tries, 'tries! 🏆🎉')Quick Check! 🧠
Test your winning-game skills! 🏆
Winning Champion! 🎉
Incredible! 🎉 You finished the whole game!
- Celebrate wins with happy messages 🎊
breakstops the loop on a win 🛑- Count tries to show how fast they won 🔢
- The loop's
elsehandles running out of tries 😅
You completed Guess the Number Game! Super proud! 🏆
print('🎉🏆 GAME COMPLETE! You are awesome! 🏆🎉')Frequently asked questions
Is the “You Win!” lesson free?
Yes — the full text of “You Win!” is free to read here on the web, and the Coding for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding for Kids course, upgrade to CoddyKit PRO.
What will I learn in “You Win!”?
Celebrate a correct guess. You practise Coding for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Coding for Kids?
No prior experience is required. Coding for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “You Win!” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Coding for Kids lesson?
Yes. Every Coding for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.