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 (Retired) Putting the "Fun" Back in "Function" Shopping List Redux

I got to minute 3 in Shopping Lists though I can't get my code to compile without an error

When compiling/running my code as shown at minute three the below is the output error.

treehouse:~/workspace$ python shopping_list.py
File "shopping_list.py", line 5
print('Enter done to stop.")
^
SyntaxError: EOL while scanning string literal

Below is my code. I found it strange that after defining the first function (def show_help() everything afterwards auto indents as if it is still part of that function so I have to delete/backspace to correct it. I think this is part of the overall problem.

shopping_List =  []

def show_help():
  print('What should we pick up at the store?')
  print('Enter DONE to stop.")


def add_to_list(item):
        shopping_list.append(item)
        print('Added: List has {} items.'.format(len(shopping.list))) 

def show_list():
        print('Here's your list:')
        for item in shopping_list:
              print(item)

show_help()

while True:
              new_item= input("> ")
              if new_item == 'DONE':
                show_list()
                break
              add_to_list(new_item)
              continue
show_list()

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Watch your quote marks and embedded quote marks:

name = input("What's your name? ")
if name == "Luke":
    print(name + " is a lumberjack and he's OK!")
else:
    print(name + " sleeps all night and " + name + " works all day!")

shopping_List = []

def show_help():
    print('What should we pick up at the store?')
    print('Enter DONE to stop.') # mismatching quote mark fixed

def add_to_list(item):
    shopping_list.append(item)
    print('Added: List has {} items.'.format(len(shopping.list)))

def show_list():
    print("Here's your list:") # Colliding quote marks fixed outer to ""
    for item in shopping_list:
        print(item)

show_help()

while True:
    new_item = input("> ")
    if new_item == 'DONE':
        show_list()
        break
    add_to_list(new_item)
    continue

show_list()