Printing out a list item by item in a function


#1


Oops, try again. Your function caused the following error: list index out of range


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


#2

a pdf? Sorry, not opening with all the ransomware going around, i know, its very likely safe. Just habits :wink:

Please copy paste your code to the forum


#3

sorry I pasted it in. Not sure why I get Oops error.


#4

here:

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

where does i come from? if you want to use i, i should also be the loop iterator (not print_list)


#5

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