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 trialAndy McDonald
Python Development Techdegree Graduate 13,801 Pointsindex 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
Haben Gebremeskel
Python Development Techdegree Student 4,569 PointsNo problem!
def pop(yolist, indexx):
newnew = yolist.pop(indexx)
return yolist
Andy McDonald
Python Development Techdegree Graduate 13,801 PointsSo 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
Haben Gebremeskel
Python Development Techdegree Student 4,569 PointsHi 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
Treehouse Moderator 68,441 PointsChanged comment to answer. Marked as best answer.
Andy McDonald
Python Development Techdegree Graduate 13,801 PointsAndy McDonald
Python Development Techdegree Graduate 13,801 PointsPlease copy and paste into answer question section so i can mark your response as best answer!