Thanks in advance
My procedure is:
Your code assumes that all elements within lists will be a list. A list may contain just numbers. So in a case where, a = [ [2, 3], 4,  ] and b = [ [3, 5], [5, 6],  ], your code will attempt to evaluate the length of the second element in a (which is an integer 4 and has no length).
Your procedure needs a third conditional that checks if only one of the two inputs is a list. Something like :
This answer is marked "community wiki".
I tested your code on several test cases and none of them produced an error but one returned the wrong value.
For reference, these were the test cases I ran:
answered 14 Apr '12, 13:11