Gives error "print_list should take exactly one argument(a list to print)"


#1

Here is my code:

n = [3, 5, 7]

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

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

print_list(n)

It gives me the error "print_list should take exactly one argument(a list to print). However, it only takes one argument in my code. Why does it give me this error? Did I do something wrong, or is it a bug? Also, I did indent correctly, but it doesn't keep it.


#2

That's what the buttons in the post editor are for

What that error really means is that your function may raise a TypeError, such as for:

print_list(["hello"])


#3

First of all, what does 'Post editor' mean?
Second, what do you mean by TypeError?


#4

I think i figured it out.


#5

What is the solution you found, please?


#6

This worked for me:
n = [3, 5, 7]

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

print_list(n)

It did not work the first time I ran the code. However, I submitted the "for" loop and print command unindented and received an error message. Then I indented properly, resubmitted, and it worked. Must be a glitch.