Passing a range into a function


#1



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


My code did not show any error. However, the instruction is to 'return a list containing [0,1,2] and I get [0,2,4] probably because of "x[i] = x[i] * 2" at line 3. So I tried to put "print my_function(range(3/2))" to neutralize the effect of line 3. But it would create an error and not go through, presumably because I can't put any fraction in the element of the function?

Please help how to return [0,1,2] with the line 3 in effect, other than removing line 3. Thanks!


Replace this line with your code.


#2

This is not how range() is used. It must be given integers.

print my_function(range(3))

The lesson passes whether the list is wrong (times 2) or not. To see the list requested in the instructions, just remove * 2.


#3

The instructions is poorly worded.

They are asking you to actually return [0 , 2 , 4], not [0, 1, 2].


#4

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