I’ve recently started learning python by watching Youtube videos. One example I came across is to code a guessing time, with the answer being “Monkey” and one can take 3 guesses max.
However, for the 3rd guess, despite the guess being wrong, it printed out “You win” (see below). Could someone please help me debug this and opine on how the code should be revised to achieve the desired result? Many thanks!
Enter guess: da
Enter guess: d
Enter guess: dafs
You win!
Hey there, i think the current problem with the code “you win” is being printed regardless of whether the user’s final guess is correct / not, you need to make ensure “you win” is printed if guess matches secret _word, sorry i used (monday)
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.