Problem with a 'break' statement. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Problem with a 'break' statement. (/thread-27761.html) |
Problem with a 'break' statement. - christopher3786 - Jun-20-2020 I have indented and have tried moving the 'break' statement around, but I keep receiving this error. What am I doing wrong? Thank you! prompt = "\nPlease enter the name of a city you have visited:" prompt += "\n(Enter 'quit' when you are finished.) " while True: city = input(prompt) if city == 'quit': break else: print(f"I'd love to go to {city.title()}!")
RE: Problem with a 'break' statement. - ndc85430 - Jun-20-2020 Clearly, your if and else statements aren't insider the loop. Lines 5 and 8 should be indented at the same level as line 4 and so on.
RE: Problem with a 'break' statement. - DPaul - Jun-20-2020 Hi, Maybe you want to examine the indentation starting line 5. Paul RE: Problem with a 'break' statement. - pyzyx3qwerty - Jun-20-2020 Your indentation from line 5 is wrong - they aren't in the loop |