12/12 Help me, pronto!


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


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


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)


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


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

That is it


thanks :slight_smile: