code: def nth(lst, n):
      
      expect_type(n, (String, Number), unit=None)
  
      if isinstance(n, String):
          if n.value.lower() == 'first':
              i = 0
          elif n.value.lower() == 'last':
              i = -1
          else:
              raise ValueError("Invalid index %r" % (n,))
      else:
          # DEVIATION: nth treats lists as circular lists
          i = n.to_python_index(len(lst), circular=True)
  
      return lst[i]
docs: Return the nth item in the list.