Python – a tuple useful for


I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this different from a list?

Best Answer

  • Tuples are used whenever you want to return multiple results from a function.
  • Since they're immutable, they can be used as keys for a dictionary (lists can't).