I've spent a good half an hour trying to figure out what's wrong, it's probably obvious


#1



https://www.codecademy.com/en/courses/python-beginner-nzzVa/3/2?curriculum_id=4f89dab3d788890003000096#


"Oops, try again. double_list([0, 1]) returned None. Did you remember to return the result? "


The code is supposed to double everything in a given list, and right now I get
-
6
10
14
None
None
-
which gives an error message.

Right now I have 'print n[i]'; 'return n[i]' gives a less correct answer.


n = [3, 5, 7]
def double_list(x):
    for i in range(0, len(n)):
        n[i] = n[i] * 2
        print n[i]
# Don't forget to return your new list!

print double_list(n)


#2

if you need to return something, use the return keyword


#3

Where your code says "print n[i]" should say "return" instead of print, and that should be spaced evenly with your "for" statement.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.