Confused


#1



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


It works.


I'm just confused in how this works.
When python runs "print my_function(range(3)), range(3) is essentially the list = [0, 1, 2].
So if we put [0,1,2] in my_function(x) ... why does it print out [0, 2, 4].
Shouldn't it print out..
[0]
[0, 2]
[0, 2, 4]

Replace this line with your code. 
def my_function(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x

print my_function(range(3)) # Add your range between the parentheses!


#2

No, because the print statement says to output the whole list.


#3

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