2dbi

Difference between tuples and lists in Python

viaGlassdoor

Problem Explain the differences between tuples and lists in Python.

Be ready to discuss

  • Mutability: lists are mutable, tuples immutable.
  • Hashability: tuples of hashable elements can be dict keys / set members; lists cannot.
  • Performance: tuples are slightly lighter and faster to construct and iterate.
  • Typical use cases: tuples for fixed/heterogeneous records and keys; lists for homogeneous, growing collections.
Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account