Learn Python – 4.3: Tuples – Lists That Refuse to Change

Lists are flexible.Sometimes a little too flexible. You can change them, reorder them, remove things, add things, and accidentally ruin your program without noticing right away. Tuples exist for the moments when Python should say: “No. This stays exactly as it is.” What Is a Tuple, Really? A tuple is a collection of items, just […]
Learn Python – 4.2: Indexing – Finding Things Like a Treasure Hunter

So now Python can remember many things at once. That’s great. But there’s an obvious follow-up question: “Okay… how do I get one specific thing out of the list?” That’s where indexing comes in. Indexing is how you tell Python where to look. The Big Idea: Positions, Not Names Lists don’t store items by name.They […]
Learn Python – 4.1: Lists – Python’s Shopping Cart of Data

So far, Python has been dealing with one thing at a time. One name.One number.One answer. That’s fine for small programs.But real programs need to remember lots of things. That’s where lists come in. A list is Python saying: “I’ll keep all of these together for you.” What Is a List? A list is a […]
Learn Python – 4.0: Collections – Make Python Remember More Than One Thing

So far, Python has been pretty good at remembering things. A name.A number.A single value stored in a variable. That works… until it doesn’t. Because real programs don’t deal with one thing at a time.They deal with many things. Many names.Many scores.Many items.Many answers. And writing this: name1 = “Alex” name2 = “Sam” name3 = […]
Learn Python – 3.5: Mini-Project – Guess the Number

Your first real loop-powered Python game. You’ve taught Python how to: Make decisions Repeat itself Stop when it’s time Skip things on purpose Loop inside loops That’s more than enough to build something that actually feels like a game. So let’s do exactly that. We’re building Guess the Number: a classic beginner game where Python […]
Learn Python – 3.4: Nested Loops: Loops Inside Loops (Loop-ception!)

When Python Repeats Things Inside Other Repeated Things. Yes, the name sounds intense. Nested loops are exactly what they sound like:a loop inside another loop. Before you panic, this is not as bad as it sounds. You already understand loops.Now we’re just stacking them. The Big Idea (Before Any Code) A nested loop means: “For […]
Learn Python – 3.3: Break and Continue – When Enough Is Enough

Teaching Python When to Stop (or Skip Ahead) Loops are powerful. Sometimes too powerful. You’ve already seen that loops can repeat code many times — maybe even forever if you’re not careful.So Python gives you two simple tools to stay in control: break → stop the loop completely continue → skip the current round and […]
Learn Python – 3.2: While Loops – The Persistent One That Never Stops

Teaching Python to Repeat Until Something Changes For loops are polite. You tell them exactly how many times to repeat, and they do it.Five times? Five times.No more. No less. While loops are different. They don’t care about numbers.They care about conditions. A while loop says: “As long as this is true… keep going.” And […]
Learn Python – 3.1: For Loops – The Organized Repeater

Teaching Python How to Repeat Things Without Losing Count Loops are Python’s way of saying: “I’ve got this. Go get a coffee.” And for loops are the most polite, organized version of that. You use a for-loop when you already know how many times something should happen, or when you want to go through a […]
Learn Python – 3.0: Loops – Teaching Python to Repeat Without Complaining

Or: How to Stop Doing the Same Thing Over and Over Up until now, Python has been pretty obedient… but also a bit lazy. If you wanted something to happen five times, you had to write it five times.Ten times? Ten lines.A hundred times? …yeah, no thanks. Real programs don’t work like that. They don’t […]