Which data structure in Python would you use to store a collection of unique elements?

  • Dictionary
  • List
  • Set
  • Tuple
You would use a Set in Python to store a collection of unique elements. Sets do not allow duplicate values, and they are commonly used to work with unique items. Lists (option 1) and Tuples (option 2) allow duplicate elements, and Dictionaries (option 4) store key-value pairs.
Add your answer
Loading...

Leave a comment

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