I have a python list as follows:
['a', 'c', 'ab', 'abc', 'bc', 'b']
I need the output as:
['a', 'ab', 'abc','b', 'bc', 'c']
To build the original list, my code is:
def buildString( s):
arr = []
for i, c in enumerate(s):
for j in range(i, len(s)):
temp = ''
for k in range(i, j+1):
temp += s[k]
arr.append(temp)
x = set(arr)
result = list(x)
return result
print buildString('abc')
This program is to build complete subsequences of an input string in lexicographic order