So, I am trying to solve a problem which involves finding the maximum depth of a tuple (for example, depth(('a',('b','c','d'),('e','f','g'))) should return 2 and depth(('a', ('b',), ('c', ('d', ('e',), f), ('g', 'h', 'i')))) should return 4. I am trying to use recursion to solve the problem where I use a counter 'c' to keep track of depth of each tuple (within the main tuple). The problem is,I get the following error, local variable 's' referenced before assignment.
My code is something like:
s=0
def depth(tuple):
do something
s=s+1
depth(some_nested_tuple)
return
What am I doing wrong?