This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by relwe
over 9 years

A bug in the error message

this is my code for exercise 4.1: n = [3, 5, 7]

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

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

print_list(n)

and this is the error message: Oops, try again! The body of your function should not contain any references to ‘n’

But there is no reference to n in my code… how can I fix it?

Answer 52127947abf8216692000b33

12 votes

Permalink

You have to remove the code that they left there. So the for i in range(0, 3): print n[i]

Has to be removed.

points
Submitted by Korey Burkholder
over 9 years

2 comments

jzu over 9 years

Not quite sure why you’d use ‘range’ when it hasn’t been explained yet. I just used for i in lst Suggest the question be updated with removal of the ‘helpful’ code, since it only needs to be removed. I think the ‘hint’ area is a better place for it.

xsz about 9 years

note: if you just comment those lines with #hashtags, that’s still not enough

Answer 53ad10af8c1ccc6a7d0021e6

3 votes

Permalink

I am not really sure why, but this code worked for me:

n = [3, 5, 7]

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

print_list(n)

Unfortunately, it looks like there is a bug in this course that is causing a fair amount of confusion.

points
Submitted by Jared Hill
over 8 years

Answer 52127b47548c35d09f000c06

0 votes

Permalink

Thank a lot!

points
Submitted by relwe
over 9 years

Answer 5362ed307c82ca472b00050b

0 votes

Permalink

There are bugs…

And there are codeacademy created bugs…..

points
Submitted by feesgo
over 8 years

Answer 53ef646e282ae347140012c3

0 votes

Permalink

I had the same problem. Seems like every next course has more bugs in it than it predecessor.

points
Submitted by L_D_J
over 8 years

Answer 552189ca9376768b19000487

0 votes

Permalink

It is a bug. I actually commented that code segment but still got the error message. After I removed that code snippet the green light is on.

points
Submitted by arthurhawk
over 7 years