Discuss A logical error of some kind.. in the Python Programming forum on Dev Shed. A logical error of some kind.. Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
Time spent in forums: 37 m 33 sec
Reputation Power: 0
A logical error of some kind..
I'm completely new to this forum (and to python as well!).
Basically, I've been learning python 3.11, and for the life of me, I cant understand why the following code doesn't work the way I want it to (I've tried searching the forums, but I'm afraid I was a tad unsuccessful, sorry).
Anyway the code is as below. I basically want a 'while loop' to keep on um.. looping when the user types in either yes or y. Any other answers would break the loop. However, the code below keeps looping regardless of whether the answer is anything but "yes" or "y".
## This is the offending while loop.
answer = "yes"
while answer.lower() == "yes" or "y":
answer = input("\n Would you like to keep on looping? ")