I have an idea. Why not use the ascii_lowercase
constant?
For example, running the following code:
# string module contains the constant ascii_lowercase which is all the lowercase
# letters of the English alphabet
import string
# Example value of s, a string
s = 'aaabcabccd'
# Result variable to store the resulting string
result = ''
# Goes through each letter in the alphabet and checks how many times it appears.
# If a letter appears at least once, then it is added to the result variable
for letter in string.ascii_letters:
if s.count(letter) >= 1:
result+=letter
# Optional three lines to convert result variable to a list for sorting
# and then back to a string
result = list(result)
result.sort()
result = ''.join(result)
print(result)
Will print 'abcd'
There you go, all duplicates removed and optionally sorted