cconnected.
Understand the pattern. Find your own way.Find your starting point
Your learning feed/Idea 1 of 218
Start small01 / 218

Put a few things in a row

Picture

Home, park, café. That’s a little list of places to visit. Order matters: home comes first. Python gives each place a position, starting at zero.

Predict

The positions are 0, 1, and 2. Which place is at position 1?

Let's look

The park. Position 0 is home, so position 1 is the next place.

A little Python, if you want it
stops = ["home", "park", "cafe"]
assert stops[1] == "park"
assert len(stops) == 3

stops[1] asks for one place. len(stops) counts the places. We call the numbered position an index. A list can also contain repeated values.

Change one rule

Put a shop before home. Is the park still at position 1?

Let's try it

No. The park moves to position 2. A position describes where something is now, not a permanent name for it.

Connect

Next, visit the places one at a time. Later, a sliding window will look at a small part of a list.