# List Element Modification

Hi

what is the error?

n = [1, 3, 5]

n[1] = n[1] * 5
print n[1]

Error message: did u accidentally remove print statement that was on line 4.

1 Like

Try to print the whole list, instead of the 2nd element only

But the instructions are:

On line 3, multiply the second element of the n list by 5

1.On line 3, multiply the second element of the n list by 5

2.Overwrite the second element with that result.

3.Make sure to print the list when you are done!

1 Like

n = [1, 3, 5]

n[1] = n[1] * 5
print n

6 Likes

I liked your answer for this. I got the right answer too. I just donâ€™t understand why. In my mind I was thinking n[1] * 5

print n

It has been a while since Iâ€™ve started back studying Python on codecademy. Can you explain what is happening here with the n[1]=n[1]*5?

Thanks!!

If you do n[1] * 5 you multiply 3 with 5 nothing more nothing less.
But if you do n[1]=n[1]*5? you multiply 3 with 5 and overwrite the current number of n[1].
-> n[1] equals n[1]*5

1 Like

Here is the code:-

n = [1, 3, 5]
n[1]=n[1]*5
print n

this one is better:-
n = [1, 3, 5]
â€śâ€ťâ€śhere we multiply the 2nd (index no. 1) element by 5 and overwriting it to the original listâ€ť""
n[1]=n[1]*5
print n

1 Like