I have tried this code to find depth of an expression.Could you tell me where I am going wrong and what I should do to get the correct answer.
k=0
m=0
def fn(x):
    global k,m
    if isinstance(x,(tuple,list))== False : return "xyz"
    if isinstance(x,(tuple,list))== True :
        k=k+1
        if k>m: m=k
        for i in x:
            print i
            print k
            if isinstance (i,(list,tuple)):
                fn(i)
            else:
                if k>1: k=m
                else:k=1
fn([[['x',[1,[8,9],2],'y',[7,6]]]])
print "depth is",m                
 
     
     
     
    