Modifying each element in a list in a function - HELP - :((


#1

MY CODE

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 ERROR - Oops, try again. double_list([0, 1]) resulted in an error: list index out of range

I just don't get it! I tried to indent - changed letters - etc - it won't work - :((


#2

It says that you're using an index that isn't valid, right?
So how are you producing your indexes? How should the function decide which indexes to use?


#3

Can you help me - please - do you know the answer?


#4

I am stuck - I can not go any further -or is there a way to skip this lesson? or I must subscribe and pay to get professional help?
Is this a way to make people pay too- at the end of the day - this is a great course and free- so why not pay too?


#5

I think that's the definition of professional help :confused:

I'm a regular user with the ability to remove spam posts. My interests are different from those of codecademy.

And my interest is not in getting people past exercises, but in showing them how to solve problems.
Advisors might be much more likely to just hand over the answer, and that makes sense, they have a product to sell and need to appease you. Me, on the other hand, I'm only interested in helping you understand what's going on. ;)


#6

I gave you three leading questions. Answering them will say a lot about what you need to change. If you can't answer them, then you can ask about that. Or, if you can answer them but don't know what to do next, then you can explain what your answers are, I can then see if your observations/reasoning make sense and help you with how to go from there.

If you don't have the patience for learning how to use the information that you have, then you're really just asking others to "do it for me"


#7

hard way of teaching ...but your cross questions helped me to think and get through the error... thank you


#8

You need an empty list for x:

x = []


#9

A post was split to a new topic: Calculation error on my part, but I'm not sure


#10

Hi
What do you mean by that?
An empty list for x ?

this x = [] - where do I have to place it into my code to make it work?

I tried - but still won't work?

Ah.......


#11

Did you not find your mistakes, yet? I think you can safely pass on the advice in the above post #9.


#15