Home > Software design >  Is there a way to fix my python Wordle program?
Is there a way to fix my python Wordle program?

Time:03-28

I am new to python and am building a wordle program in simple python. I will attach the code below: (Note- to understand this question you will have to be familiar with the game "Wordle" (enter image description here

As you can see, when the word "facts" is entered, it is saying that the letter "a" is grey, whereas in fact it should be yellow, and the letter "c" is "yellow", where it should in fact be "grey". The given output for "facts" is

grey
grey
yellow
grey
grey

where it should actually be

grey
yellow
grey
grey
grey

On the other hand, for the words "falts" and "blank" it is giving the right output. Please help me fix this problem.

CodePudding user response:

You have confused guess_word with word. In this case, the solution to your wordle is "facts" and you are guessing the word "blank". If you print out check you will see what the issue is:

b
grey
l
grey
a
yellow
n
grey
k
grey

Indeed, the third letter "a" is found in the word "facts"

CodePudding user response:

i = 0
while 1>0:
    guess_word = "blank"
    word = input()
    while i <= 4:
        check = word[i]
        if check in guess_word:
            if guess_word.find(check) == i:
                print("green")
            elif guess_word.find(check) != i:
                print("yellow")
        else:
            print("grey")
        i = i   1
  • Related