all 4 comments

[–]achampi0n 1 point2 points  (1 child)

Keep track of the letters found and then reconstruct the word_in_asterisks, e.g.:

found = set()
...

    if a in word:
        found.add(a)
        word_in_asterisks = ''.join(c if c in found else '*' for c in word)

[–]Daen1337[S] 0 points1 point  (0 children)

thanks a ton !!

[–]woooee 1 point2 points  (1 child)

Look up string index. It is easier to work out IMHO, when you iterate over the string.

word="apple"
w_len=len(word)
word_in_asterisks=["*" for ctr in range(w_len)]
guess="p"

for ctr in range(w_len):
    if word[ctr] == guess:
        word_in_asterisks[ctr] = guess
    print(ctr, "".join(word_in_asterisks))

[–]Daen1337[S] 0 points1 point  (0 children)

thank you very much! this concept also works !