I want to generate all substrings of size k-1 from a string of size k.
e.g 'abcd' should give me
Order of these strings in the list doesnt matter.
Also order doesnt matter inside the string e.g 'abc' or 'bca' or 'bac' is the same.
The following code doesnt give the full output(iteration over each string)

subsetList = []
prunedNew = ['abcd']
for element in prunedNew:
    for i in range(0,2):
        subsetList.append(element[i:i+len(element)-1])
        continue
    continue
 return prunedNew

Thanks,
girish

Could you enlighten me, what is this all used for?

actually i'm implementing an algorithm in PYthon...right now there are parts of it that i need to rectify...

i think the following code may solve your problem, it was thought up by a friend of mine, i merely did the typing, so i take no credit, but i think this is your solution:

def main():
    string = "abcd"
    k = len(string)
    a = 0
    SubStrings = []
    while k > 0:
        SubStrings.append(string[0:a]+string[a+1:])
        k -= 1
        a += 1
    return SubStrings
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.