# 14/18 Passing Range into a Function...math doesn't make sense?

#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
My code behaves fine…but the list printed is [0, 2, 4] and the lesson asks me to return a list with [0, 1, 2]

<What do you expect to happen instead?>
I understand the difference between return and print, however the function looks like this:

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

So if I pass a range of 3 into the function, it takes 0, 1, and 2 and doubles them, and then returns the list. Since the doubling happens before the return, isn’t it actually RETURNING a list of [0, 2, 4]?

If so, it would seem that this code fails to return a list of [0, 1, 2], but yet the website counts this as correct. I don’t understand this.

```python

Replace this line with your code.

<do not remove the three backticks above>

#2

The exercise wants the user to supply a range that returns [0, 1, 2]. It may not be entirely clear that it is not asking the user to have my_function return [0, 1, 2]. Instead, it wants the user to notice that when given a range that returns [0, 1, 2], the function will return [0, 2, 4]. Since that is what you noticed, you’ve done exactly what the exercise wanted you to do.

#3

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