2017-03-05 80 views
-2

我想找到给定的双数组中的子数的数量。如何计算python中的给定数组中的子数组?

例如,

Input: aaa=[[4,3,1],[3,1,1,1,3],[-1,-2,3],[4]] 

Output: number(aaa) = 4 

Input: bbb=[[4,3,1],[],[3,1,1,1,3],[-1,-2,3],[4]] 

Output: number(bbb) = 4 

你能帮助我吗?

+0

在最后一个例子中'number(bbb)= 4'是什么? – RomanPerekhrest

+0

我认为你的最后输出必须是5 –

+0

我想说非空子数的数量。 –

回答

0

你可以使用简单的len()基本python方法。