0
0
Pythonprogramming~15 mins

List concatenation and repetition in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
List concatenation and repetition
๐Ÿ“– Scenario: You are organizing a small party and want to prepare a list of snacks to serve. You have two lists of snacks from different stores and want to combine them. Also, you want to repeat some popular snacks multiple times to make sure there is enough.
๐ŸŽฏ Goal: Build a Python program that creates two snack lists, combines them into one list, repeats some snacks, and then prints the final snack list.
๐Ÿ“‹ What You'll Learn
Create two lists of snacks with exact items
Create a variable for the number of repetitions
Concatenate the two snack lists
Repeat a snack list using the repetition variable
Print the final combined and repeated snack list
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Combining and repeating lists is useful when managing inventories, menus, or any collection of items where you want to merge or duplicate entries easily.
๐Ÿ’ผ Career
Understanding list operations like concatenation and repetition is fundamental for data handling, automation scripts, and preparing data for analysis or display in many programming jobs.
Progress0 / 4 steps
1
Create two snack lists
Create a list called store1_snacks with these exact items: 'chips', 'cookies', 'nuts'. Also create a list called store2_snacks with these exact items: 'soda', 'juice'.
Python
Need a hint?

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

2
Create a repetition count
Create a variable called repeat_count and set it to the number 3. This will be used to repeat some snacks later.
Python
Need a hint?

Just assign the number 3 to the variable repeat_count.

3
Combine and repeat snack lists
Create a new list called all_snacks by concatenating store1_snacks and store2_snacks. Then create another list called popular_snacks by repeating store1_snacks exactly repeat_count times.
Python
Need a hint?

Use the + operator to join lists and the * operator to repeat a list.

4
Print the final snack lists
Print the all_snacks list and then print the popular_snacks list, each on its own line.
Python
Need a hint?

Use two print() statements, one for each list.