I want to generate 'substrings' from a string as follows:
for each substring j of string,generate the 2 lists [j,string - j] and [string -j,j]
e.g If i have a string 'abc' i want to generate the list [['a','bc'],['bc','a'],['c':'ab'],['ab','c'],['b':ac],['ac':b]]
Now i tried the following but its not giving me the desired output :( ....can anyone help??
def gensubset(colocation): rulesList= [ ] length = len(colocation) for i in range(0,length,1): rule1 = [colocation[i:i+1],colocation[i+1:length]] rule2 = [colocation[i+1:length],colocation[i:i+1]] rulesList.append([rule1]) rulesList.append([rule2) continue return rulesList