Python Tutorial · Revision notes

Python Tuples

A tuple is an ordered, immutable collection. You will learn how to create tuples, pack and unpack them, slice them, and use their two methods count() and index().

Quick revision

  • Tuple: ordered, immutable, ( )
  • Comma creates tuple: (5,)
  • Unpacking :a,b=t;a,∗rest=t\text{Unpacking}\ : a, b = t; a, *rest = t
  • Only count() and index()
  • sorted(t) returns a list
  • Hashable if all items hashable
Read the full Python Tuples notes on Doubtclip →