← Learn to Code — Python for Beginners
Module · Put It Together
Mini project: number guessing game
Time to combine everything: variables, if/else, loops, and input — into one real, working program.
Read through the code below, run it, and try changing the secret number or the number of attempts allowed.
New here: break immediately stops a loop early — used below once the guess is correct, so the game doesn't keep asking. The else at the end of the while loop runs only if the loop finished without hitting break — that's how it knows the attempts ran out.
This is genuinely what programming looks like day to day — small, familiar pieces combined to do something a bit more interesting. Once this feels comfortable, you're not a beginner anymore.