The new things I had learn while learning python #3 - While loop


🌀 What is a while loop?

A while loop is like saying:
👉 “Keep doing this thing again and again, as long as this condition is true.


💬 Real-life Example:

Imagine I say:

“Babe, keep giving me kisses until I fall asleep 😴.”

That’s a while loop in real life 😘💋



💥 What happens here?

  1. count = 1 → this starts at 1

  2. while count <= 3: → this checks: “Is count 1, 2, or 3?”
    If yes → go inside and do the code.

  3. print("I love you 💖") → prints the message.

  4. count += 1 → adds 1 to count (so it becomes 2, then 3, then 4...)

When count becomes 4, the loop stops because 4 <= 3 is false.

Comments

Popular posts from this blog