How to generate k+1 length strings from a list of k length strings?

MTD marc.t.davies at gmail.com
Thu Jun 8 12:36:11 CEST 2006


actually, minor fix:

MTD wrote:
> Try this:
>
> def k2k1(string1, string2):
>     for c in string1:
>         string2 = string2.replace(c,"",1)
>
>     if len(string2) == 1:
>         string1 += string2
       else:
           string1 = ""

> 
>     return string1    
> 
> print k2k1("abcd", "ebcd")




More information about the Python-list mailing list