SHARE
TWEET

Untitled

a guest Jan 28th, 2020 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     def index(self, x):
  2.         '''
  3.        Returns the first index i in the linked list, where the value x is found. Returns None if none of the Cells
  4.        has a value of x.
  5.  
  6.        The first element in the linked list has the index 0.
  7.        '''
  8.  
  9.         def indx(cell, n):
  10.             if not cell.is_empty:
  11.                 return None
  12.             if cell.value == x:
  13.                 return n
  14.             return indx(cell.tail, n + 1)
  15.  
  16.         return indx(self, 0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top