A set in Python is a linear data structure we use to store elements without allowing duplicates.
A set that maintains the insertion order of the elements is called the OrderedSet
. We can find it in the sortedcollections
module.
OrderedSet(iterable=())
iterable
: This is an iterable of elements.The method returns a set that maintains the insertion order of the elements.
from sortedcollections import OrderedSetiterable = '85678756's = OrderedSet(iterable)print(s)
OrderedSet
from the sortedcollections
package.OrderedSet()
with the defined iterable
.