Skip to content

Commit 65ebeff

Browse files
Create Nesting_Structure_Comparison.py
1 parent fc4efe7 commit 65ebeff

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

4 kyu/Nesting_Structure_Comparison.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def same_structure_as(original,other):
2+
count = 0
3+
if(type(original)==type(other)):
4+
if(len(original)==len(other)):
5+
for x in range(len(original)):
6+
if(type(original[x])==type(other[x])):
7+
if(isinstance(original[x], list)):
8+
try:
9+
if(len(original[x]) == len(other[x])):
10+
print(len(original[x]), len(other[x]))
11+
if(type(original[x][0])==type(other[x][0])):
12+
count+=1
13+
except:
14+
count+=1
15+
else:
16+
count+=1
17+
else:
18+
if(isinstance(original[x], list)==isinstance(other[x], list)):
19+
count+=1
20+
21+
else:
22+
return False
23+
return True if count==len(other) else False

0 commit comments

Comments
 (0)