pip install ordered-set from ordered_set import OrderedSet letters = OrderedSet('abracadabra') print(letters) # {'a', 'b', 'r', 'c', 'd'}