0
0
Pythonprogramming~15 mins

Iterating over lists in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Iterating over lists
📖 Scenario: You are helping a small bookstore organize its daily sales data. The store records the number of books sold each day in a list. You will write a simple program to go through this list and work with the sales numbers.
🎯 Goal: Build a program that creates a list of daily book sales, sets a target sales number, counts how many days met or exceeded the target using a loop, and then prints the count.
📋 What You'll Learn
Create a list called daily_sales with the exact values: 12, 7, 15, 9, 20, 5
Create a variable called target and set it to 10
Use a for loop with the variable sales to iterate over daily_sales
Inside the loop, count how many days have sales greater than or equal to target
Print the final count using print(count)
💡 Why This Matters
🌍 Real World
Counting how many days meet a sales goal helps businesses understand their performance and plan better.
💼 Career
This skill is useful for data analysis, reporting, and automating simple business tasks.
Progress0 / 4 steps
1
Create the daily sales list
Create a list called daily_sales with these exact values: 12, 7, 15, 9, 20, 5
Python
Need a hint?

Use square brackets [] to create a list and separate numbers with commas.

2
Set the target sales number
Create a variable called target and set it to the number 10
Python
Need a hint?

Use the equals sign = to assign the value 10 to the variable target.

3
Count days meeting the target
Create a variable called count and set it to 0. Then use a for loop with the variable sales to iterate over daily_sales. Inside the loop, add 1 to count if sales is greater than or equal to target.
Python
Need a hint?

Start with count = 0. Use a for loop to check each sales. Use an if statement to compare sales with target. Increase count by 1 when condition is true.

4
Print the count
Write a print statement to display the value of count
Python
Need a hint?

Use print(count) to show the final number of days meeting the target.