Why loops are needed
📖 Scenario: Imagine you have a list of fruits and you want to say hello to each fruit. Doing this one by one is slow and boring. Loops help us do this quickly and easily.
🎯 Goal: You will create a list of fruits, set up a counter, use a loop to greet each fruit, and then print all greetings.
📋 What You'll Learn
Create a list called
fruits with these exact items: 'apple', 'banana', 'cherry'Create a variable called
greetings and set it to an empty listUse a
for loop with variable fruit to go through fruitsInside the loop, add the string
"Hello, {fruit}!" to greetingsPrint the
greetings list💡 Why This Matters
🌍 Real World
Loops are used in many real tasks like sending emails to many people or checking items in a list.
💼 Career
Understanding loops is important for any programming job because they help automate repetitive work.
Progress0 / 4 steps