Passing a range into a function


Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: range() integer step argument expected, got float.

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

print my_function(range(0,2,0.5)) # Add your range between the parentheses!


The instruction says start at 0, end before 3 and increment value by 1. So, the definitive range that correct answer is range(0, 3, 1), range(0, 3) or range(3).


oh ok thank you! i thought it meant it wanted the output to be [0,1,2]

i changed the range to be (0,3,1)


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