Lesson 5.6
A tuple is a list that cannot be changed. It is written in round brackets:
point = (3, 5)
print(point[0]) # 3
print(len(point)) # 2
Everything you did with a list — indexes, slices, len, looping — works with a tuple
too. But point[0] = 7 raises a TypeError: a tuple is immutable. That's why it is
used where the data must not change: coordinates, colour, size.
Careful: (3) is just a number in brackets. A tuple of one item is written with a
comma: (3,).
The coordinates x and y are set by the check. Build the tuple point from them and
print:
len.A tuple is values in round brackets separated by commas.
Build (x, y), then print it, the item with index [0] and len(...).
Don't confuse it with a function call: there is no function name before the brackets here.