Python ยท Lesson 5 of 5

๐Ÿงบ Lists

Keep many values together in one list.

A list holds many values in order, inside square brackets. The first item is at position 0.

fruits = ["mango", "apple", "banana"]
print(fruits[0])
fruits.append("grapes")
print(len(fruits), "fruits")
OUTPUTmango 4 fruits
marks = [80, 65, 92]
print("Total:", sum(marks))
print("Best:", max(marks))
OUTPUTTotal: 237 Best: 92

โœ๏ธ Your turn

Open this example in the playground, change it and run it.

โ–ถ Try it yourself

๐Ÿง  Quick quiz

In ["a", "b", "c"], which position is "b"?