Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Shopping List App Shopping List Introduction

sai jayanth kashyap
sai jayanth kashyap
3,293 Points

i am getting an error saying "break outside loop"

while executing the same program i am getting an error saying break outside loop. what does that suppose to mean? am i intending the break incorrectly? print("Enter your today schedule") print("Enter Done when done with scheduling")

todo_list = [] while True: list = input("> ") todo_list.append(list)

if input == 'done': break

print(" Here is your all day schedule") for todo in todo_list: print(todo)

A neat trick:

when posting code, type three "backticks" + "python": ```python on the line above your code and 3 backticks on the line below your code block. It formats your text like python code and makes it way easier for us to read and help out with!

For instance, as of right now, the formatting in your code is incorrect (I'm sure you typed it correctly, but due to quirks of html it is displayed wrong), so it is very difficult (if not impossible) to tell where you went wrong in your code because I can't see how you indented everything.

(I am basically saying the same thing Nate Stugeon said)

When posting code, please format it so it is readable to other people :)

When posting (python) code, put ```python and ``` around your code like this:

```python

name = "Alex"

print("Why, hello, {}!".format(name))

```

the thing above will turn into:

name = "Alex"
print("Why, hello, {}!".format(name))

Which looks much nicer and is way easier to read.

Please always provide formatting when posting code.

Thanks! ~alex

3 Answers

sai jayanth kashyap
sai jayanth kashyap
3,293 Points

ohokay, i didn't know about that. I am sorry. Thankyou.

Can you re-post your code please (in a formatted way)?

sai jayanth kashyap
sai jayanth kashyap
3,293 Points
print("Enter your today schedule")
print("Enter Done when done with scheduling")

todo_list = []
while True:
  list = input("> ")
  todo_list.append(list)

if input == 'done':
        break

print(" Here is your all day schedule")
for todo in todo_list:
  print(todo)

This was my code sir.

Now that you've formatted your code, it is clear that your indentation is incorrect. You want your if input == 'done': to be inside your while loop, that way when it becomes true, it breaks out of this while loop.

Change your indentation level so that it is within the while loop code block:

while True:
  list = input("> ")
  todo_list.append(list)

  if input == 'done':
    break

Also, if I remember correctly, in this coding challenge 'done' should be in all caps: 'DONE'

Finally, there is another issue with your code. It has to do with the if... break clause, can you spot it? (hint: you don't have a variable named input)