This forum is now read-only. Please use our new forums! Go to forums
12/18 Printing out a list item by item in a function
I am getting some error here. Even after writing the code correctly(atlas I feel so), I am getting error. anyone else with the same issue
n = [3, 5, 7]
#for i in range(0, len(n)):
# print n[i]
def print_list(x):
for k in range(0,len(x)):
print x[k]
return x
print_list(n)
The error I am getting is
Oops, try again. The body of your function should not contain any references to ‘n’
Answer 557c5527d3292f7047000085
It’s work! n = [3, 5, 7]
def print_list(x): for k in range(0,len(x)): print x[k] return x
print_list(n)
Answer 557ca7f793767634b200024e
Михаил Кириллин had it correct, you need to remove/modify the entire first for loop for the code to work correctly
Answer 557c73fce39efed2900001c6
Answer 55817eae9113cbf08f0006e1
I have the same problem :
n = [3, 5, 7]
def print_list(x): for k in range (0,len(x)): print x[k] return x
print_list(n)
Oops, try again. It looks like you either didn’t call print_list(n) or there is something wrong because 5 wasn’t printed.
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
1 comments
Thanks..It worked.. he irony is commenting those lines don’t work but completely removing them do :)