Your code is actually not printing anything. All you see in your terminal window is the input you asked the user to enter. When you call input("Message")
in python, the message gets printed to the terminal and awaits user's input
input("Please enter Y/N: ")
> [input]: Please enter Y/N: ...
At this point, if you type "what", your for loop checks if it's in the list you provided. Since it's not there it prints the input message again. In Your case, it prints the message 3 times before you enter the correct value.
To see the program succeed you could print something at the end
x = input("Y/N? ")
while x not in ["Y","N"]:
x = input("Please enter Y/N: ")
print("YaY, you finally entered:", x)
Will output:
> [input] Please enter Y/N: what
> [input] Please enter Y/N: is
> [input] Please enter Y/N: Y
> [output] YaY, you finally entered: Y