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

Andy McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andy McDonald
Python Development Techdegree Graduate 13,801 Points

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

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

No problem!

def pop(yolist, indexx):
    newnew = yolist.pop(indexx)
    return yolist
Andy McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andy McDonald
Python Development Techdegree Graduate 13,801 Points

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 68,457 Points

Changed comment to answer. Marked as best answer.