# This is file listparts.py def ends(l): return [ l[0], l[len(l)-1] ] # return a list of the first and last elements def middle(alist): # return a list of middle one or two elements length = len(alist) if ( length % 2 ) == 0 : # Even length return [ alist[length/2-1], alist[length/2] ] # return list of size 2 else: # Must be odd length return [ alist[length/2] ] # return list of size 1