Re: How to generate all k-1 level substrings of a string?

2006-06-05 Thread K.S.Sreeram
Girish Sahani wrote: > I want to generate all substrings of size k-1 from a string of size k. > e.g 'abcd' should give me ['abc','abd','bcd','acd'] def get_sub_set( s ) : return [s[:i]+s[i+1:] for i in range(len(s))] >>> print get_sub_set( 'abcd' ) ['bcd', 'acd', 'abd', 'abc'] Regards Sreeram

How to generate all k-1 level substrings of a string?

2006-06-05 Thread Girish Sahani
I want to generate all substrings of size k-1 from a string of size k. e.g 'abcd' should give me ['abc','abd','bcd','acd'] 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. I wrote the following code but it doesnt g