# Stuck on something quite simple, help needed

#1

i just cant figure this one out, I know it's probably not that hard but ive gotten stuck on it, so please somebody explain. ive posted the reset code below because my code is very muddled up. thank you

``````def list_function(x):
return x[1]

n = [3, 5, 7]
print list_function(n)``````

#2

Hey there!
The instructions state that you need to add 3 to the number represented by index [1].

You've got most of this right!
But you got the main part wrong, here's where it went wrong:

``return x[1]``

Instead of this ^^ It should be something like this.

``````x[1] = x[1] + 3 #this line is a bit self explanatory
return x``````

Hope this helped you out

#3

You'e made a good start. What instructions are asking is that 3 is added to the element at spot 1 of the list. And then that the result is store in that spot.

To access spot 1 we use `x[1]`. Adding 3 is as simple as `x[1] + 3`. To store the result back in that spot we simply have to assign `x[1]` to the equation, so `x[1] = x[1] + 3`.

Finally we return the whole list by using `return x`.

#4

thank you guys, I get it know, I didn't realise I had to delete the 'return x[1]' line

#5

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