14/18 Lesson on range but no range needed


#1



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

I think there is a bug in 14/18, lists and functions.

The instructions are to input a range that will return 0, 1, 2. If you just make a new list that has the values 0, 1, 2 in it, it should return 0, 2, 4 which is does. The problem is is that it says that that is the correct answer and takes me to the next lesson. You don't even have to put in a range for it to accept the answer.


def my_function(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x
n = [0, 1, 2]
print my_function(n) # Add your range between the parentheses!


the result is:
[0, 2, 4]
None
and then it tells me to go to the next lesson.

Was there something that I am missing in this lesson or is there a bug?


#2

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!

That's what I did.
I don't see a reason for n = [0, 1, 2] and print my_function(n). But I guess what you did worked.
I think when they said n = [0, 1, 2], they mean a transformed version of it, since 0*2 is 0, 1*2 is 2, and 2*2 is 4, you get 0, 2, 4


#3

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