Printing out a list item by item in a function


#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/lists-and-functions/exercises/printing-out-a-list-item-by-item-in-a-function?action=lesson_resume

Why is this not working?

```python

Replace this line with your code.
n = [3, 5, 7]

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

def print_list(x):
print x[i]
return x

print_list(n)

<do not remove the three backticks above>

#2

I finally managed to solve the exercise, but still don’t understand why my first code didn’t work :(:


#3

the instructions say:

Use the existing code as a scaffold.

You have to convert the given code to a function. If you write new code, the provided code has to be removed, otherwise the exercise won’t approve it


#4

Thanks a lot. I didn’t think about that.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.