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

I have a question

Kenneth Love, I didn't understand what you told us during the Shopping List Take Three. on your lecture, 7:04 you said that 'Position minus one because I've been showing them the positions with the one. So we need to Decker meant this back so it's zero based.And if the position isn't none then the position minus one we're going to insert the item. Can you explain this easily? Thank you.

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

So, we've been showing what's on the list, right? Like I had output similar to:

1. apples
2. oranges
3. milk

We want to let people add things onto the list at certain locations, or delete particular items from the list. We want to let them do this by specifying the location in the list to do the thing they want to do.

So if the user wants to delete "oranges" from the list, they'd input the number 2, because "oranges" has a 2 next to it. In our list, though, "oranges" is stored at index 1 ("apples" would be at index 0, because indexes in Python always start at 0). Because of this, we have to decrement (or reduce) the number they give us by 1.