I am trying to create a decision prompt for a loop with python 3.6. But it does not work
def cycle():
looping = "yes"
while looping == "No" or "no" or "n" or "N":
looping = input('Do you want to make a new calculation? \n \t (Y/N)')
if looping == "No" or "no" or "n" or "N":
looping = "yes"
break
elif looping != "No" or "no" or "n" or "N":
print('This is not the right answer')
looping="no"
Can somebody help me out with this code? Thank you!
As well as the comparison error that Jean-François Fabre pointed out, there's a logic error here too. To simplify a little bit, this is the code in your example:
The
while
loop never starts. You should write:or as Jean-François said,
Then you're converting someone's "No" answer into a "yes"...?
Why not try staying in the loop forever unless the user provides valid input: