Rullst AcademyRullst Academy/Lesson
Python: from first line to project · Lesson 05 / 12

One list, many possibilities

Three missions need 10, 20 and 15 minutes. We can keep the durations together and inspect each position.

Learning paths9 min

Let's discover together

  1. 1

    A list uses brackets: durations = [10, 20, 15]. Order is part of the data. It does not automatically add the values.

  2. 2

    The first index is 0: durations[0] is 10. durations[1] is 20. len(durations) gives the item count: 3.

  3. 3

    durations.append(5) adds an item at the end and changes the list. There are now four items. append does not return the list: do not write durations = durations.append(5).

  4. 4

    In an empty list, len([]) is 0, but accessing [0] raises IndexError. Check that the position exists; length 3 means indices 0, 1 and 2.

✦
YOUR MISSION

Create, inspect and extend lists; distinguish index, length and value.

Now it's your turn

Discovery workshop

Read, predict, check

Compare the two versions. Show result reveals a prepared output: this panel does not run Python. Then practise with the activity file.
Mini experiment

Learning simulation: compare cards and check your predictions. The browser is not compiling Rust or starting a server.

durations = [10, 20, 15]
print(durations[0])
print(len(durations))
Build your answers and check when you are ready.
A moment to understand

In [10, 20, 15], how do index 0 and value 10 differ?

I need a hint

Count positions from zero, but items from one.

Loading your journey…

Take it with you

Create a list of three fictional durations. Show the first and the length; append another and check the new length. Explain what accessing index 99 would do.

PYTHON · .py

Your Python workbench

Here you read and predict prepared outputs. To run the actual code, download the activity file, edit it on your computer and use Python. Rullst Academy grades lesson answers; it does not verify local execution.

Save and run

Extract the activity ZIP into its own folder. Open a terminal there and use your system’s command. If downloading your edited file separately, use its actual name in the command. Save before running again.

Windows
python lesson.py
macOS / Ubuntu
python3 lesson.py
My files and GitHub

The editor keeps a local draft and can send a .py file to GitHub with your confirmation. Download your edited code to preserve it. The ZIP is starter material; for the final project, also publish data and test files following PUBLISH.md.

At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.