I have the following piece of code.
def num_dim(response_i, m):
for response_j in response_i['objcontent']:
if response_i['objkey']== 'explorecube_dimvalues':
mm = [response_j['title']]
m.append(mm)
m=(len(m))
return m
if __name__=='__main__':
for response_i in response['response']:
m=[ ]
x=0
def num_dim_2(response_i, m):
if response_i['objkey']== 'explorecube_dimvalues':
m = num_dim(response_i, m)
print(m)
return m
num_dimentions= num_dim_2 (response_i, m)
print(num_dimentions)
The output for print(m) is:
3
but the output for print(num_dimentions) is:
[ ]
[ ]
3
[ ]
which I expected only 3.
Anyone knows how can I fix this issue (get the value of 3 as the final output). Thank you.
min your functions (which is a list and so passed-as-reference), and you are also returning it?! It does not make sense. The entire piece of code is gibberish.