Lists – Creation, online

Six activities your students do on their own devices. See who's finished, and their scores.

Lists – Creation in one minute

What students need to know

A list is an ordered collection of items written inside square brackets, like colors = ['red', 'blue', 'green']. An empty list is created with just []. Each item is called an element, and len(list) returns how many elements it contains. Lists can hold any type of value — numbers, strings, even other lists — and the order items are added in is the order they stay in.

Mistakes students make

  • Using parentheses instead of square brackets — colors = ('red', 'blue', 'green') — creates a tuple, not a list, which behaves differently (it can't be changed after creation).
  • Square brackets are what make it a list.

Discover other journeys with this module

What students will learn in this module

Every question in Module 33

Quick questions

  1. How do you create a list?ASquare brackets []BParentheses ()
  2. What does [] create?AAn empty stringBAn empty list
  3. Can a list hold different types?AYes strings, numbers, booleans, etc.BNo only one type
  4. What does len([1, 2, 3]) return?A2B3
  5. Are list items ordered?AYes they keep their orderBNo random order

Key terms

Students type the meaning of:

  • List
  • []
  • Element
  • len(list)

Match the pairs

nums = (1, 2, 3)
nums.append(4)
Match it to what it does
items = [1, 2, 3
print(items)
Match it to what it does
colors = ['red', 'blue', 'green']Match it to what it does
mixed = [1, 'hi', True, 3.5]Match it to what it does
nums = [1, 2, 3]
print(len(nums))
Match it to what it does
items = []
print(items)
Match it to what it does

Fill in the blanks

  1. colors = _'red', 'blue', 'green'_
  2. numbers = [10, 20, 30]
    print(___(numbers))
  3. empty = __
  4. pets = ['cat'_ 'dog'_ 'fish']
  5. names = ['Alice', 'Bob']
    _____(names)

Spot the error

Question 1

A# Create a list of colorsBcolors = ('red', 'blue', 'green')Cprint('First:', colors[0])Dprint('Count:', len(colors))

Question 2

A# Create a list of colorsBcolors = {'red', 'blue', 'green'}Cprint('First:', colors[0])Dprint('Count:', len(colors))

Question 3

A# Create a list of colorsBcolors = ['red' 'blue' 'green']Cprint('First:', colors[0])Dprint('Count:', len(colors))

Question 4

A# Create a list of numbersBnumbers = [1, 2, 3,]Cprint('First:', numbers[0])Dprint('Count:', len(numbers))

Question 5

Acolors = [red, blue, green]Bprint('First:', colors[0])Cprint('Count:', len(colors))Dprint('Done')