0

Whenever I have a duplicate letter in a word on this code, it seems to only display the first letter.

I've tried changing rfind (which finds the right most character) to just find but still doesn't help.

This is the code:

while True: 
    guess = input("What letter are you guessing?")
    if guess in animal:
        print("Correct")
        if (animal.find(guess)) == 0:
            print("This letter is in the 1st position")
            turtle.goto(-430,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 1:
            print("This letter is in the 2nd position")
            turtle.goto(-310,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 2:
            print("This letter is in the 3rd position")
            turtle.goto(-190,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 3:
            print("This letter is in the 4th position")
            turtle.goto(-70,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 4:
            print("This letter is in the 5th position")
            turtle.goto(50,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 5:
            print("This letter is in the 6th position")
            turtle.goto(170,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 6:
            print("This letter is in the 7th position")
            turtle.goto(290,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 7:
            print("This letter is in the 8th position")
            turtle.goto(410,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 8:
            print("This letter is in the 9th position")
            turtle.goto(530,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))
        if (animal.find(guess)) == 9:
            print("This letter is in the 10th position")
            turtle.goto(650,0)
            turtle.write(guess, move=False, align="left", font=("Arial", 60, "normal"))

This is the part that checks if any of the letters are correct, I have more code for incorrect letters elsewhere.

0 Answers0