This forum is now read-only. Please use our new forums! Go to forums
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
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.
Answer 53ad10af8c1ccc6a7d0021e6
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.
Answer 5362ed307c82ca472b00050b
Answer 53ef646e282ae347140012c3
Answer 552189ca9376768b19000487
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.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
2 comments
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.
note: if you just comment those lines with #hashtags, that’s still not enough