You have a function that needs to return multiple values, which data structure is more commonly used for such a purpose?

  • Dictionary
  • List
  • Set
  • Tuple
Tuples are commonly used to return multiple values from a function because they are immutable (cannot be changed), ensuring data integrity. This makes them a safer choice than lists, which are mutable. Using a tuple also communicates that the returned values should not be modified.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *