Micro Challenge #21 – Using lists to create images

22 May 2020 - 3 minute read

Welcome to the twenty-first of Altitude Foundation’s #MicroChallenges2020

Today’s challenge will help you create pixel art using lists!

What’s a Micro Challenge?

These challenges are short activities to help you develop, revise or refresh your coding skills, posted every Monday, Wednesday and Friday.

Micro Challenge #21

Following on from Wednesday’s fun with Python and Monday’s experimentation with pixel art, today we’re going to continue thinking about how we can use programming to create images. 

Lists are used in programming to store information. For example:

List = [Arsenal, Chelsea, Liverpool, Manchester City, Newcastle United] 

This list stores the names of a series of Premier League clubs. In this list, Arsenal is indexed at ‘0’ and Newcastle United is indexed at ‘3’ – in the order they appear in the list. (You can learn more about this in Challenge 17).

Lists can give us another way of creating pixel art – so, rather than using coordinates, we can use a binary list. In this list 1=a coloured-in pixel and 0=a black or white pixel. So for a 5×5 grid, we could create this:

Line1 = [0,0,1,0,0]

Line2 = [0,1,0,1,0]

Line3 = [1,0,0,0,1]

Line4 = [0,1,0,1,0]

Line5 = [0,0,1,0,0]

And then combine this into a Grid using a multi-dimensional list (a list which combines multiple other lists). We can do this in two ways, either:

Grid = [Line1, Line2, Line3, Line4, Line5]


Grid =[[0,0,1,0,0], [0,1,0,1,0], [1,0,0,0,1], [0,1,0,1,0], [0,0,1,0,0]] [Note: If we use this model, we don’t need to create the initial lists!]

It may seem like the second model is always easier. However, if you want to select specific pixels, for example to change their colour, the line model might give you more flexibility. For example: 

Line1[2], Line5[2] = “purple” ← this allows you to change the tips of your diamond shape to purple. 

The Challenge:

What can you create using this system? Be as creative as you like – you might want to create a Space Invader, a digital rainbow, retro game images…The grid can be as large or small as you want to make it – just add more pixels to your list.

It might be helpful to visualise what you are creating to ensure your pixels are in the right place.

Review it:

  • Can you use your code to recreate the image you intended?
  • Following this tutorial, could you use Turtle to actually programme your art in Python?


  • Building on the skills you’ve developed this week, you might want to look at one of these challenges, based on twentieth century visual artists: Victor Vasarely, Vera Molnar.

Share it

We would love to see what you have created! Please send any pictures, videos, or files of your activities to us – either via Facebook, Twitter or Instagram  using #MicroChallenges2020 or to challenges@altitudefoundation.org. If you are emailing them to us, please let us know if you are happy for us to share your stuff on our social media platforms (with credit, of course).

Sign-up here to receive a weekly email with Micro Challenges top tips and solutions:

Leave a comment

Leave a Reply