|
Hello! I 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, [3] ] and b = [ [3, 5], [5, 6], [4] ], 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 :
link
This answer is marked "community wiki".
Thanks for the answer but I my Idea (eclipse, pydev) says it runs just fine. (Evaluate to false) 1
Try this :
Your code throws a TypeError. Also, as @cthompson says below, if d = [1] and e = 7, your code evaluates to True, which is clearly wrong. Sorry, the example in my answer above was an example I just made up but didn't test. If you compare a number and a list, at the top level, you'll get the TypeError. 1
You have made me realise that I shouldn't be lazy and I should write my own test cases. I just used ones I found on the forums and clearly they're not exhaustive enough. Thanks! Stupid me. Thanks for the help! |
|
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:
|