Printing out a list item by item in a function


#1


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


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)



#2

the output is good, but the error is there, if possible kindly help me understand the error thank you..!


#3

def print_list(x):
for i in x:
print (x[i])

is this code good, it still gives error?


#4

also ,
should i use print or return to call function with the arguement

thank you


#5

Hello,

There is no error in the code actually, but how codecademy is grading your code.
You should only remove this:

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

final code:

n = [3, 5, 7]

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

print_list(n)


#6

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