how to get distinct letters from a string in python code example
Example 1: how to get all distinct substrings in a string python
def substr(string):
j=1
a=set()
while True:
for i in range(len(string)-j+1):
a.add(string[i:i+j])
if j==len(string):
break
j+=1
return a
Example 2: python count distinct letters
string = 'aabbcd'
unique = []
for char in string[::]:
if char not in unique:
unique.append(char)
print(len(unique))