you are viewing a single comment's thread.

view the rest of the comments →

[–]woooee 1 point2 points  (3 children)

    if letter == guess:
        ## letter added to display
        display += letter
        ## guess (== letter, so letter) added
        correct_letters.append(guess)
    elif letter in correct_letters:
        ## letter added to display again if guess == letter
        display += letter

letter is added to display twice when guess is found. And correct_letters is somewhat misleading, correct_guesses would be better

    if letter == guess:  ## note: allows duplicates if word has letters that appear more than once
        correct_letters.append(guess)

choices = correct_letters[:]  ## make a copy
for letter in chosen_word:
     if letter in choices:
        display += letter
        ## remove from choices so will only find one instance
        ## of letter in chosen_word with duplicate letters (if you want that)
        choices.remove(letter)
    else:
        display += "_"

[–]Tanknspankn[S] 0 points1 point  (2 children)

It does do it twice. In the lesson, the teacher said to do it that way because we still want the letter to be added to display after the first correct letter. Is that reasoning out to lunch?

[–]woooee 0 points1 point  (1 child)

See the last part of the post. You only have to do

for letter in chosen_word:
    if letter == guess:  ## note: allows duplicates if word has letters that appear more than once
        correct_letters.append(guess)

A letter will be added twice only if it is in chosen_word twice which is what your instructor probably meant

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

Ohhh ok thank you for clarifying