9. Using an element from a list in a function


#1




Oops, try again. list_function([7, 4, 8, 8]) returned 8 instead of 4


instructions : Change line 2 so that list_function returns only the item stored in index ONE OF x, rather than the entire x list.
but Why not x[0] or x[2]??
I'm not a native English speacker so it might be my language problem...


Replace this line with your code. 
def list_function(x):
    return x[2]

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


#2

Only one minor detail you missed, you just need to change your return index to 1 and not 2,

to,

return x[1]


#3

but it says to return the first item of the list. wouldnt this be in position [0]


#4

Actually it does not say the first item but actually the item in index one,

Change line 2 so that listfunction returns only the item stored in index one of x, rather than the entire x list._


#5

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