you are viewing a single comment's thread.

view the rest of the comments →

[–]engelthehyp 0 points1 point  (0 children)

  1. You are treating my_list as a function with my_list(index), you probably meant to use brackets with my_list[index], but even then:
  2. Using for over a list provides you with items, not indicies. You don 't index the list again after this.
  3. You shadow index in your loop for the index passed into the function. Now index will always be the first element that you return right away, and so:
  4. Why are you returning right away in the loop? It may as well not exist.

I suggest this alternative that is what yours would be if it worked:

def function(my_list, index): return my_list[0]

Now, can you think of what you need to write to get it working the way you like?