C. lookup(L, k): return the kth item in the mylist, where indexing starts at 0.

From EECS 182
C. lookup(L, k): return the kth item in the mylist, where indexing starts at 0.
Jump to: navigation, search
  1. Problem C: return the kth item in L. k starts at 0.
  2. lookup(mylist().append(4).append(3), 1) should be 3

def lookup(L, k):

   return L[k:k+1].last()
  1. You should try doing the problem without the benefit of the indexing operation as well. It is possible to do it with only using last() and pop().
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
EECS @ UM
Tools