[BUG] 12/18 Body of function should not reference n anywhere


#1

** I understand removing the commented code will solve the issue, but I want to report that leaving in the commented out code should not affect whether an answer is right or not**

For my answer to Printing out a list item by item in a function I wrote

n = [3, 5, 7]

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

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

However, I received the error message The body of the function should not reference n anywhere. The error message went away after I removed the commented code. This seems like a bug to me.


#2

same thing is happening to me m8, does anyone mind helping ;-;


#3

Ay my IT teacher helped out alot, here is the answer m8:

n = [3, 5, 7]

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

print_list(n)


#4

Yes, so I think the issue is that the codecademy software is looking at commented out code when checking answers. Is there a way to report a bug?


#5

all you have to do is change "n" to "x"

x = [3, 5, 7]

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


#6

Yes, I was able to solve the problem, but I would like to report to codecademy a bug in their software where the algorithms are examining commented out code to determine if an answer is correct or not.


#7

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


#8

Yes, I understand that is the correct answer. If you look at my previous replies you will see it's not that I couldn't figure out the answer, but that I wanted to report a software bug where codecademy is looking at commented out code to deem what is correct or not.


#9

correct one


#10

PLEASE refer to earlier replies from me.


#11

Had the same issue.
Error is NOT the result of the code used (the function) but rather the checker is reading the commented (#) out section. The whole point of commenting out lines is so they will not be read by the code. As a beginner, getting errors for the correct code because the checker is reading commented out lines is frustrating to be sure.
Removing the commented out lines resolves but it should not be generating error on these lines to begin with.
Oddly enough, having the example range commented out in the same way does not produce an error in the next lesson (13/18).


#12

Way too many of the lessons are buggy. I have found numerous bugs other than what is mentioned here. Some have wasted my time and caused me to get so frustrated that I almost went Nuclear and ejected subatomic particles out of my eye sockets.


#13

y = [3, 5, 7]

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

print_list(n)

simply change n to another algebraic value


#14

I can relate. If it was better, I might consider getting a paid account. But as it is, I'm not going to.
Also, next time you think you're going to go nuclear, please record it so that I may watch you emit radiation from your eyes. :smile:


#15

I can not understand this section of the course.
Can someone please help me out?
Thanks a lot in advance


#16

I get it. You have to get rid of the original 'for' function for it to pass.


#17

Solution is simple:

delete the provided code snippet

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

Either write your function around it or move the snippet. Don't let it stay in the code by itself.

edit: as @reianna_bryant said.