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
web die
714 Pointspop() with index
when you used pop with index at 01:32, you didn't used the [], can we do it in python calling index in parentheses? hope you understand
1 Answer
Chris Freeman
Treehouse Moderator 68,468 PointsThe method pop operates like a function, in that, it's arguments are wrapped in parens ().
items = ["a", 3, "b", 9]
# remove first item using del
del items[0] # removes the "a",
# remove first item using pop
item_removed = items.pop(0) # removes the 3
# item_removed now holds 3
web die
714 Pointsweb die
714 PointsThanks
web die
714 Pointsweb die
714 PointsCan you pls explain me what is happening here:
Chris Freeman
Treehouse Moderator 68,468 PointsChris Freeman
Treehouse Moderator 68,468 Points