12/18 Printing out a list item by item in a function

3 Likes

return print_list(n) #remove return

n = [3, 5, 7]

def print_list(x): #Define a function called print_list that has one argument called x
for i in range(0, len(x)): #Inside that function, print out each element one by one. change x to n.
print x[i]

print_list(n) #Then call your function with the argument n.

that dosent work for me

n = [3,5,7]

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

print_list(n)

that didnt work for me::scream:

n = [3, 5, 7]

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

print_list(n)

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

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

I had to REMOVE all of the code they proved and got the following to pass:

x = [3, 5, 7]

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

print print_list(n)

1 Like

[details=Summary]This text will be hidden[/details]


it works

Thank you!!! That is so odd!

I, too, had to delete all their provided code. That’s SO frustrating. -___-