12/12 Help me, pronto!


#1



My teacher told me to do this code since it was the answer, but it gave me the error, "The body of your function should not contain any references to 'n' ".


n = [3, 5, 7]

for i in range(0, len(n)):
    print n[i]
n = [3, 5, 7]
def print_list(x):
    for i in range(0, len(x)):
        print x[i]
        return x

print_list(n)


Please give me the error and/or the correct code! :worried:


#2

i might hope not, because it is not the answer.

The exercise gave you the loop as start:

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

to put this loop inside the function and modify the loop. But you made a new loop, which is fine but remove the loop which is outside the function.

You don't need to return x (the list)


#3

So the only thing I need is the def and the print_list? Or do I also need to print something else?


#4

You need a function which loops over the list and prints each item in the list

That is it


#5

thanks :slight_smile:


#6