Printing out a list item line by line


#1


https://www.codecademy.com/courses/python-beginner-nzzVa/3/1

It says Oops, try again. The body of your function should not contain any references to 'n'


Even though the code works perfectly and prints the list each number to its own line, it still says that the body of the function should not contain a reference to 'n' which it doesn't. I replaced all the 'n's with 'x's like is said to do in the hint.


def print_list(x):
    for i in range(0, len(x)):
        print x[i]

print print_list(n)


#2

The function is doing the printing, as implied by its name. No need to print the return value, None.


#3

So should I change the print to a return in the function?


#4

No, just remove the print from the call statement.

print_list(n)

is all you need. It will do the printing.


#5

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

print_list(n)


#6

Like this? I took out the print statement and it gave me the same error


#7

Oops, try again. The body of your function should not contain any references to 'n'


#8

This was the error given after I removed the print statement


#9

So this is what you have so far?

def print_list(x):
    for i in range(0, len(x)):
        print x[i]

print_list(n)

This assumes there is a list named n.


#10

Yes
def print_list(x):
for y in x:
print y

print_list(n)


#11

Well then you should be passing.


#12

It's not. It still gives me the same error that I am referencing n in my function body.


#13

This was the error that I received.


#14

Is the line print_list(n) indented? If so, remove the indentation.


#15

No, it isn't. It is outside of my function.


#16

If this helps it is still outputting none:
3
5
7
None
That is my output


#17

Save your code and refresh. Give everything a look over and submit again. We're missing something, and starting the session over helps to clear the cogs.


#18

Ok. Also here is all the code from this lesson. Maybe some of this is causing the error
n = [3, 5, 7]
"""
for i in range(0, len(n)):
print n[i]
"""

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

print_list(n)


#19

Tried refreshing and no dice. It still is giving me the same error.


#20

I'll try restarting the whole browser.