14. Passing a range into a function. Problem. error


#1

Hi all,
I have attempted to copy and paste several times lines of codes from other users that "worked" for them but I always get the " Oops, try again. It looks like you didn't pass a range consisting of 0, 1, 2 to my_function." error message.

I decided to alter the code to make sure it outputs [0,1,2]. It does! and I am still told that it does not.

x = [0, 1, 2]

def my_function(x):
for i in range(0, len(x)):
x[i] = x[i] *1
return x

print my_function(range(3))

And this is the output:

[0, 1, 2]
None

I am starting to think that it is broken but then again, some people apparently got it.

Running my code both on Python Tutor or on Coding Ground outputs the expected 0, 1, 2.

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


#2

Did you change this line? It should be times 2.

I think there may some confusion over the instruction:

On line 6, replace the ____ with a range() that returns a list containing [0, 1, 2].

This could be construed to imply the return value of the function, but it is actually meant as a range() that returns, meaning range(3) => [0,1,2].

The output of the function will be a list, [0, 2, 4].


#3

thanks, I reloaded the page and code I had used before magically started to work after that


#4

A post was split to a new topic: There is something wrong with the instructions here


#5