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 Second Shopping List App

Justin Bigos
Justin Bigos
3,828 Points

Second shopping list. printing out incorrect item # in list

After adding an item to my list the console is printing out the item# wrong. My first item will say 'List now has 1 item', after entering a second item it prints 'List now has 3 items' adding a third produces 5 items in list an on and on.

def add_to_list(new_item): shopping_list.append(new_item) print("Added {}. List now has {} items.".format(new_item, len(shopping_list)))

Justin Bigos
Justin Bigos
3,828 Points

sorry code pasted linear. It didn't look like that in when pasted it with my question.

1 Answer

Justin Bigos
Justin Bigos
3,828 Points

Nevermind, I found my mistake. It works as it should. Have to say figuring it out is very satisfying.