12. Printing out a list item by item in a function


#1


I'm a bit confused, it says the body of my function should not contain any reference to 'n'. And also that I have a syntax error on line 7... I don't really understand because surely we don't have a list for x?


n = [3, 5, 7]

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


#2

first of all, you are missing a color at the end of this statement.

second, could you please post a link to the exercise you are working on. Thank you.


#3

https://www.codecademy.com/courses/python-beginner-nzzVa/3/1?curriculum_id=4f89dab3d788890003000096

I've put the colon in now and it's still coming up with the error


#4

I don't quite understand why you have that first for loop. Go ahead and remove it.

Next:

Let me know what you get when you try the above...


#5

That was part of what they gave me... When I get rid of it is says "did you create a function called print_list?"


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

That should work. For the code they give you, you need to build your function around that code, with the correct indentation.


#7

To clear up any confusion on this problem, delete this form your answer....


#8

However,I get an error that "The body of your function should not contain any references to 'n'"

Here is my code:
n = [3, 5, 7]

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

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

print_list(n)


#9

I have the indent in the line which it needs.


#10

Try deleting this portion and running it again.


#11

Ok,thank u very much!


#12

I'm getting the same error with my code. Something seems broken, and I don't think it's my own code this time.


#13

Dears,

It works only if you removed

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

so your code should be as below