0 votes
1 view
in Data Science by (7.5k points)

My python code is stuck in a loop. I have tried making it break. But that has not helped.

It is below:

Adetails = input("Enter flight details (Please enter the three-letter code for the UK airport): ")

while Adetails != "LPL" or "BOH":

    Adetails = input("Error three letter airport code invalid. Please enter either LPL or BOH: ")

Any help would be appreciated.

1 Answer

0 votes
by (15.3k points)
edited ago by

This is not the correct syntax to test the or condition:

while Adetails != "LPL" or "BOH":

It must be written like this to work (and notice that we need to use and here, not or!)

while Adetails != "LPL" and Adetails != "BOH":

Or equivalently:

while Adetails not in ("LPL", "BOH"):

Do check out Data Science with Python course which helps you understand from scratch  

Welcome to Intellipaat Community. Get your technical queries answered by top developers !