Jay Rosenthal Jay Rosenthal - 22 days ago 5
Python Question

While loop not accepting the break function, classed as syntax error?

Am in the middle of a project for school and am trying to use a while True loop in order to get a specific answer from an input. I tried the following and IDLE labels break as a syntax error.

while True:
RequestTea = input("What tea would you like? English Breakfast, Green Tea or Earl Grey? ").lower()
if RequestTea.lower() not in ('earl grey','english breakfast','green tea'):
print("Not an appropriate choice.")
else:
break


Can anyone please help? I don't see why it's not accepting the loop function.

Thank you very much!

Answer
while True:
    RequestTea = input("What tea would you like? English Breakfast, Green Tea or Earl Grey? ").lower()
    if RequestTea.lower() not in ('earl grey','english breakfast','green tea'):
        print("Not an appropriate choice.")
    else:
        break

Indent blocks