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.


Nataly Rifold
Nataly Rifold
12,431 Points

I keep getting EOFError and I have no idea why

Hi, I keep getting EOFError and I have no idea why, I did every thing form the Removing Items From A List video and I look over my script and I have no idea. I keep getting this message :

Traceback (most recent call last):
File "shopping_list.py", line 79, in <module>
File "shopping_list.py", line 26, in add_to_list
"> ".format(item))

The code:

def add_to_list(item): show_list() if len(shopping_list): position = input("Where should I add {}? \n" "Press ENTER to add to the end of the list\n" "> ".format(item)) else: position = 0 try: position = abs(int(position)) except ValueError: position = None if position is not None: shopping_list.insert(position-1, item) else: shopping_list.append(new_item)

1 Answer

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

There are a few obvious issues and since python is indentation based we need to see formatted to help more.

To post your code check the Markdown Cheatsheet Code section below each post for detailed info. For python on separate lines...

line 1 - three backticks "`" (to the left of the 1 above the tab on a US standard keyboard) followed by the word "python" (no quotes - just used for emphasis)

line 2 through end of code - copy in your code

line n after code - three more backticks

I think the eof error is because of all the quotes in the Input statement

you are also putting conditions after else: commands - maybe you intended to use elif?

Also you are not using double equal signs in conditionals - remember == in an if statement and = for assignment.

The other thing I noticed is you did is not None which should be != None

Hope that's a start.