|
Sir, you have said in the question that "if lists contain the same elements in the same structure ...", but sample outputs show that the two given input lists p and q need not contain "same elements", but same number of elements. Ex: 1st sample output (i agree with all other statements you have specified). This is what i have interpreted from the question. correct me if i am wrong sir. |
|
Given the examples given in the homework description, I would agree with your interpretation.
print same_structure([1, [2, [3, [4, 5]]]], ['a', ['b', ['c', ['d', 'e']]]]) >>> True print same_structure([1, [2, [3, [4, 5]]]], ['a', ['b', ['c', ['de']]]]) >>> False |
|
Try to create the tree for both the inputs - they should match in the shape but the leaf values may be different. So, they have same structure but the values may not be the same. |
|
In the case:
Have they the same structure???? |