0
0
Pythonprogramming~15 mins

zip() function in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the zip() function to combine lists
๐Ÿ“– Scenario: You work in a small shop and have two lists: one with product names and one with their prices. You want to pair each product with its price to see them together.
๐ŸŽฏ Goal: Learn how to use the zip() function to combine two lists into pairs.
๐Ÿ“‹ What You'll Learn
Create two lists with exact values
Create a variable to hold the zipped pairs
Use the zip() function correctly
Print the zipped pairs as a list
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Combining related data from separate lists is common in shopping apps, inventory systems, and data analysis.
๐Ÿ’ผ Career
Understanding zip() helps in data processing tasks, making code cleaner and easier to read in many programming jobs.
Progress0 / 4 steps
1
Create two lists of products and prices
Create a list called products with these exact items: 'apple', 'banana', 'cherry'. Then create a list called prices with these exact numbers: 0.99, 0.5, 2.5.
Python
Need a hint?

Use square brackets [] to create lists and separate items with commas.

2
Create a variable to hold zipped pairs
Create a variable called product_price_pairs and set it to the result of zip(products, prices).
Python
Need a hint?

The zip() function takes two lists and pairs their items by position.

3
Convert zipped pairs to a list
Convert product_price_pairs to a list and store it in a variable called pairs_list.
Python
Need a hint?

Use the list() function to turn zipped pairs into a list you can see.

4
Print the list of product-price pairs
Print the variable pairs_list to display the combined product and price pairs.
Python
Need a hint?

Use print(pairs_list) to show the final result.