List element modification


n = [1, 3, 5]

Do your multiplication here

for x in n:
x= n[2]*5
print n

Oops, try again. Did you remember to multiply the second element in the list by 5?
Somehow, I'm lost on basic on lists, though not sure where

On line 3, multiply the second element of the n list by 5
Overwrite the second element with that result.
Make sure to print the list when you are done!


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

Your code is using the third element (index) "[2]", not the second, "[1]".

There might be more to it but that's what I noticed off the bat, see if that helps.


That's what I'm not getting here... what is the code to multiply the element from the list without using for


Yeah i got stuck on this as well.
here's what i did that wasn't working: n = [1, 3, 5]
n[1]= n[1]*5

                                                 print n

It was working but instead of overwriting the number 3 or [2] with 15, it would just add 15 to the list in index [2] and push the number 3 to index[3] and so on.
so i just deleted the append line and it worked: n = [1, 3, 5]
n[1]= n[1]*5

                                                               print n

def over thought that one. hope that helps!


sorry, that didn't copy and paste right.


Thanks mate....That helped


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