Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (Retired) Putting the "Fun" Back in "Function" Shopping List Redux

file function_list.py and for some reason, I keep getting a warning telling me that function_list.py is not defined.

i can't check if my code is right because it never runs due to this error message. But then I get error messages at every turn. Here's the code.

shopping_list = ()

def show_help():
  print("What should we pick up at the store?")

 print("Enter DONE to stop. Enter HELP for this help.")

def add_to_list(item):

  shopping_list.append(item)

   print("Added: List has {} items.".format(len(shopping_list)))

show_list()

while True:

  new_item = input(">")

  if new_item == 'DONE'
       break
  elif new_item == 'HELP':
    show_help()
    continue
  add_to_list(new_item)
  continue

  show_list()

I really hope this shows correctly.

William Li
William Li
Courses Plus Student 26,865 Points

what's the error message? and what's your code?

well, that's the issue. I can't get it to run, because when I try to run the script, I keep getting the syntax error or it says, "function_list.py is not defined." . so after I type in the script name to run it, I get the error message. This is really getting disheartening. Seems like everyday I'm writing a help question.

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

So you've put all of that code into function_list.py? When you try to run it, do you see >>> on the left side? If so, you're still in a Python shell and need to exit() out of it.

You have some indentation problems all over that code, btw. Make sure things are indented consistently.

thanks, Kenneth. I was in the python shell. my indentations were right, putting it on here is where the wheels fell off. Thanks for the help