0
0
Pythonprogramming~15 mins

print() parameters and formatting in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Using print() Parameters and Formatting
📖 Scenario: You are creating a simple program to display a shopping list clearly on the screen. You want to control how the items appear by using different print() options.
🎯 Goal: Learn how to use the print() function's parameters like sep and end, and how to format output with f-strings.
📋 What You'll Learn
Create a list of shopping items
Set a separator string for printing items
Use a for loop to print items with the separator
Format and print a summary line using an f-string
💡 Why This Matters
🌍 Real World
Formatting output clearly is important when showing lists or reports in programs, like shopping lists or logs.
💼 Career
Understanding print formatting helps in debugging and creating user-friendly console applications.
Progress0 / 4 steps
1
Create a list of shopping items
Create a list called shopping_list with these exact items: 'apples', 'bananas', 'carrots', 'dates'
Python
Need a hint?

Use square brackets [] and separate items with commas.

2
Set a separator string
Create a variable called separator and set it to the string ', ' (a comma followed by a space).
Python
Need a hint?

Use quotes around the comma and space.

3
Print items using the separator
Use a for loop with variable item to go through shopping_list. Inside the loop, use print() to print each item followed by the separator without moving to a new line after each print.
Python
Need a hint?

Use the end parameter of print() to avoid new lines.

4
Print a formatted summary line
After the loop, print a new line with the text Total items: 4 using an f-string and the len() function on shopping_list.
Python
Need a hint?

Use print(f"\nTotal items: {len(shopping_list)}") to start on a new line and show the count.