01.02 · Create and access lists / Watch · 12 min
Keep related values together in a list
A list holds an ordered sequence. Its length counts the items, not the letters in their names.
Activity 2 of 5 in Create and access lists
Python 3: Lists / 01.02
Create Python lists
Not started
Create ordered collections, combine them and count their items.
Your lesson progress
Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

ORIGINAL WALKTHROUGH · 6:57
Watch with Rob.
Pause whenever you want to try a change. You can return to the lesson at any time.
You are signed in, but video access needs attention. Check your account access. Your saved work is kept.
Video walkthroughs are included with an active Code Zone membership. The written lesson and practice are free.
Open video & code editor (opens in a new tab)Square brackets create a list
Put comma-separated values inside square brackets. Strings still need quotes; numbers and Boolean values keep their normal Python spelling. Empty brackets create an empty list.
A list preserves item order and allows duplicate values. It can hold mixed types, although keeping related values together often makes later code simpler.
fruits = ["apple", "banana", "cherry"]
numbers = [1, 2, 3]
mixed = ["Ada", 42, True]
print(fruits)
print(len(mixed)) # 3
print([])Combine lists without changing the originals
The + operator produces a new list with the left list’s items followed by the right list’s items. It does not add the numbers inside those lists.
The original lists remain unchanged. This distinction matters when you want a combined roster and still need each team.
first_team = ["Ada", "Rob"]
second_team = ["Grace"]
roster = first_team + second_team
print(roster)
print(first_team)
print(len(roster)) # 3Count items, not characters
len(fruits) returns the number of items. A long fruit name still occupies one list position. An empty list has length zero.
The next practice adapts the source’s create/combine/count exercises to fixed inputs so the checks can give predictable feedback. After passing, try your own animals, foods or numbers.
Build it one step at a time
Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.
The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.
Start mini-lesson(opens in a new tab)4 steps · Saved work · Instant feedback
YOUR TURN
Combine fruit lists
Create all_fruits from the two source lists and fruit_count from its length. Print the combined list, then its count. Preserve both source lists.
['apple', 'banana', 'cherry'] 3
Keep the starting inputs. Print these lines in this order, without extra output.
- Store a three-item count
- Preserve the first list
- Preserve the second list
- Store all fruits in order
Edit Python, then run it. Check challenge checks your output and the listed Python requirements. Your code saves on this browser after a short pause. Sign in and choose Save account draft to keep it across devices. Word wrap is enabled.
Ready to checkRun the checks to see your results here.
Your check results
Need a nudge?
Make a new list
Use the two existing list names on either side of +. Store that expression in all_fruits.
Count the combined items
Call len with all_fruits, rather than writing the count by hand.
One possible solution
Your code may look different and still be correct. Compare the approach with your own.
Concatenation builds a new list. Its length follows the data, so it stays useful when you add another fruit.
Walk through the fix.
Choose Next to inspect one change at a time. Highlighted lines show what to notice. Your editor stays unchanged unless you choose to load a step.
Step 1 of 2
Read the inputs
Create all_fruits from the two source lists and fruit_count from its length. Print the combined list, then its count. Preserve both source lists.
first_fruits = ["apple", "banana"]
second_fruits = ["cherry"]Expected output for this step
(No output)
Build the requested result
Concatenation builds a new list. Its length follows the data, so it stays useful when you add another fruit.
first_fruits = ["apple", "banana"]
second_fruits = ["cherry"]
all_fruits = first_fruits + second_fruits
fruit_count = len(all_fruits)
print(all_fruits)
print(fruit_count)Expected output for this step
['apple', 'banana', 'cherry'] 3
See the complete solution
first_fruits = ["apple", "banana"]
second_fruits = ["cherry"]
all_fruits = first_fruits + second_fruits
fruit_count = len(all_fruits)
print(all_fruits)
print(fruit_count)Ready to try it?
Practice in your browser and see your results.
Progress details
Have a question?
Ask the Code Zone community.
Ask a question in The Code Zone (opens in a new tab)