Microbit
Beginner
50 mins
Teacher/Student led
+170 XP

Lists and Working with Data in Python

Students build a micro:bit MicroPython project that creates and manipulates lists — retrieving, changing, adding and removing elements — then use lists of images to drive LED light patterns. Following PRIMM, they predict, run, investigate and modify working code, naming debugging as a skill along the way.

Teacher Class Feed

Load previous activity

    1 - Start: What We're Building ~5 mins

    Quick recap: last time we stored single values in variables. Today's question — what if you want one variable to hold a whole set of values, like five numbers or a row of images?

    That's a list (also called an array). We'll build a micro:bit project in Python that creates a list, reads and changes items in it, adds and removes items, and finally uses lists of images to make LED light patterns. We'll predict first, then build, run and fix as we go.

    2 - Predict Before You Run ~10 mins

    Before anyone runs anything, look at what we're about to build and commit to a prediction. When a list holds five numbers and we ask the micro:bit to show the item at position 0, which number do you think appears first? What do you expect to see after we change or remove an item?

    Say your prediction to your partner so we can check it later.

    3 - Introduction ~3 mins

    In this lesson, you'll learn the basics of working with arrays in MicroPython. You'll create a simple list, retrieve elements from the list, change elements, add new elements, and remove elements from the list. By the end of this lesson, you'll have a solid understanding of how to work with arrays in MicroPython.

    To get started, open the micro:bit Python editor at https://python.microbit.org and create a new project.

    4 - What Is an Array? ~2 mins

    An array is a collection of items, like numbers or strings, stored in a single variable. In MicroPython, arrays are often called lists. They are useful when you want to store and manipulate multiple values using a single variable.

    In this lesson, we'll use the terms 'array' and 'list' interchangeably.


    5 - Create a List ~2 mins

    Lists can store different types of data, such as integers, strings, or even other lists. For example:

    • Integer List: [1, 2, 3, 4, 5]
    • String List: ['apple', 'banana', 'cherry']
    • Mixed List: [1, 'apple', 3.14]

    Now, let's create a list called 'numbers' with five elements. The elements are the integers from 1 to 5. Add the following code to your editor:

    from microbit import *
    
    numbers = [1, 2, 3, 4, 5]
    
    This creates a list called numbers with five elements. The elements are the integers from 1 to 5.
    123learn · Online learning platform

    Unlock the full learning experience

    You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2025. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more