Remove duplicate letters in a word

Paul Rubin http
Sun Jun 22 19:25:15 CEST 2003

Eliran Gonen <eg at> writes:
> I'm stuck here:
>     for i in range(len(key)):
>         for j in range(len(key)):
>             if key[i] == key[j] :
>                 key[j] = ""
> Hope you can help me,

You can't change the contents of a string in Python.  You have to
make a new string:

    temp = []
    for c in key:
      if c not in key2:
    key = str(temp)

More information about the Python-list mailing list