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 Technical Interview Prep: Python Basics Basic Python Once You Pop

index given to .pop() is not removing correct list entry

If i put the pop index at 0 it takes the index position of 1. I don't understand why its doing this

def pop(yolist, indexx):
    newnew = yolist.pop(yolist[indexx])
    return yolist

Please copy and paste into answer question section so i can mark your response as best answer!

No problem!

def pop(yolist, indexx):
    newnew = yolist.pop(indexx)
    return yolist

So Haben.. your adding comments to the question. If you scroll down further there will be a button that says post answer or something to that effect. If you click that, and then answer. I can select it as best answer and then you can get discussion points.

1 Answer

Hi Andy! You are very close, the reason you're getting this problem is when your using yolist[indexx] it is giving you the VALUE of yolist[indexx] NOT THE ACTUAL --->INDEX NUMBER<---. You can easily fix this by replacing yolist[indexx] with just indexx.

Chris Freeman
Chris Freeman
Treehouse Moderator 67,982 Points

Changed comment to answer. Marked as best answer.