I'm really frustrated right now


#1




The function is supposed to print out each element in the list when called upon.


It does exactly what the exercise asked it to do but when i print submit, the console works perfectly fine but a message comes up and says "Oops, try again. The body of your function should not contain any references to 'n'". There is absolutely no references to 'n' in the body of my function


n = [3, 5, 7]

def print_list(x):
    for i in x:
        print i

print_list(n)


Sorry to bother but this is getting extremely annoying
#2

Hi @mohnish101 ,

Have you posted all of your code? If this loop is still there, Codecademy will not pass your submission ...

for i in range(0, len(n)):
    print n[i]

#3

no i didnt think that part was needed to see what was wrong. This is the whole code:
n = [3, 5, 7]

for i in range(0, len(n)):
print n[i]

def print_list(x):
for i in x:
print i

print print_list(n)


#4

Everything is indented like its supposed to be


#5

This code that is outside the function needs to be removed ...

for i in range(0, len(n)):
    print n[i]

However, you need to use that code as a model, so that within the function, you can use the range and len functions within the loop header. Within the loop, use an index to access the list, x, in a manner that is similar to how it was used to access the list, n, in the original loop.

If you encounter any additional problems, post your updated code, otherwise let us know that the problems have been resolved.


#6




My code does everyTHING it was asked to do.


when I hit submit, the console prints out the correct result. I COMPLETED the exercise. But then a message box comes up and says "Oops, try again. double_list([0, 1]) resulted in an error: list index out of range". First of all that was incredibly unhelpful since I have no idea what the message is saying since the course never taught "range" yet. And secondly, I literally completed the exercise with what was supposed to happen.


n = [3, 5, 7]

def double_list(x):
    for i in range(0, len(n)):
        x[i] = x[i] * 2
    return x
print double_list(n)
# Don't forget to return your new list!


#7

try replacing the len(n)) with len(x))


#8

WOW, I feel like such an idiot right now. Ive been on that one for at least 15 mins looking things over and over and somehow I kept missing that. Thank You


#9