DEV Community

Discussion on: 5 Python Tricks in one line. Beginner vs Professional

Collapse
 
jackm767 profile image
jackm767

In a post for beginners it’s probably worth mentioning that sets are unordered. If you use a set to remove duplicates you can no longer index the data. Converting back to a list may not keep the original order either (? unsure about this).

Collapse
 
vadimkolobanov profile image
Vadim Kolobanov

You are absolutely right. It may be worth adding the following

The set does not contain duplicate elements;

The elements of the set are immutable (they cannot be changed), but the set itself is changeable, and it can be changed;

Since the elements are not indexed, the sets do not support any slicing and indexing operations.