I get asked this from time to time, so for the fun of it, I’ll post this:
Tuples are immutable lists in python (and other languages). Very lightweight, unchangable arrays. They are used for storing multiple values in one variable (usually a fixed number of values).
x = (1, 2, 3, 'abc') x -> 1 x -> 2 x -> 3x -> abcx["bob"]-> TypeError: tuple indices must be integers, not str
Tuples are immutable lists in python (and other languages). Very lightweight, unchangable arrays.x = (1,2,3)x == 1x == 2x == 3x[“bob”] == “tuple indices must be integers”
A common example is storing x,y coordinances. You could use a tuple for that:point = (12,38)
Python can unpack tuples also.x,y = (12,38)x -> 12y -> 38