Python Tuple vs List
tuple vs listMissing topic

When to use a tuple instead of a list

Lists change. Tuples stay fixed. Choose tuples for records that should not be edited by accident.

Picture this: list vs tuple

List = editable row. Tuple = sealed row.

list []can append
→
tuple ()cannot change
→
pick by jobgrow vs freeze

In easy words

Both store ordered items. The big difference: you can append/change a list, but a tuple is locked after creation.

List []

  • Mutable — can grow and change
  • Good for shopping carts, queues
  • Cannot be a dict key

Tuple ()

  • Immutable — fixed after create
  • Good for coordinates, RGB, DB rows
  • Can be a dict key

Mutation demo

nums = [1, 2, 3]; nums.append(4) → OK [1, 2, 3, 4]
point = (1, 2); point[0] = 9 → TypeError (tuple immutable)
Press the button to compare.

Example Program

1n = int(input())
2vals = list(map(int, input().split()))
3t = tuple(vals)
4print(len(t))
5print(t[0])
6print(list(t) == vals)