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

Hi could you please help me with this task. I am getting an error on my pop function and i am struggling to get output.

Your help would be much appreciated, i've been stuck on this problem for really long time. I'm struggling to print range

pop.py
def pop ([1,2,3,] 1)
for i in range(0, len(l)):
       if l[i]==0:
           pop.pop(i)

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

You need to be using parameters for the input and you are supposed to return a string "Invalid Index" if the index is invalid. I got tripped up because I thought the program was supposed to throw an information error (like you would expect).

def pop(mylist, index):
    # your code goes here
    pass

Hi Jeff Muday thank you so much for your feedback. My first line is still giving a syntax error for my ([1,2,3] 1). Have i corrected the rest of my code properly?

def pop([1,2,3], 1):

for range in pop (1, len(pop)): return(range) pass