I found my code a bit difficult to debug at the end because it's still halfway decent at playing wordle. So, I fully admit I might not be doing it right!
But one thing I also did was allow it to pick a word it knew wasn't possible but could eliminate a lot of possibilities quickly.