13. Modifying each element - Why does my code not work?


#1




Oops, try again. double_list([0, 1]) resulted in an error: list index out of range


n = [3, 5, 7]

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

print double_list(n)

The outcome is correct, but it still does not work. I don't understand what's wrong..


#2

change len(n) to len(x)


#3

Thanks! Well, I really looked over that one. Can't believe I have been trying for half an hour on this.


#4

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