Need help from 2


#1

what's wrong with the followings?
(Did you remember to multiply the second element in the list by 5?)

n = [1, 3, 5]

n[1]*5

print n[1]*5


#2

you actually want to update the list item:

n[1] = #something to update the second list item

you just print it, but don't modify the list which you can see:

 n = [1, 3, 5]

n[1]*5 

print n[1]*5

print n

#3

yes, yet what do you mean multiply?
n[1]*5 isn't the multiply line?


#4

yea, but it is not actually modifying the list. look:

i = 5
print i
i + 5
print i
print i + 5
print i
i = i + 5
print i

you need to re-assign a value to n[1] to actually update the lists.


#5

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