Sign in · Sign up

Lesson 5.0

A list holds many values under one name. It is written in square brackets, with items separated by commas:

games = ["Minecraft", "Roblox", "Brawl Stars"]
print(games)   # ['Minecraft', 'Roblox', 'Brawl Stars']

Without [] and commas, "Minecraft", "Roblox" is already a tuple, and without quotes the program won't understand the words.

The check sets three prices a, b and c. Build the list prices from them in the same order and print, in order:

  1. the list prices itself;
  2. how many items it has — with len.

There is one list, and [] goes only around it: print(a) instead of print(prices) prints a plain number, not a list.

Hint

A list is built once: prices = [a, b, c] — the items are separated by commas and taken from variables, not typed in by hand.

A ready list is printed without extra brackets: print(prices).