I am adding up the elements from all of the nested lists, so far what I have is
for i in range(len(b)) :
for j in range(len(b[i])):
total = total + b[i][j]
But this will not work when an integer value exists in the nested list like,
b = [[1,2], [3,4], [5,6], 1]
In this case i am getting an error message that object of type ‘int’ has no len().
what should i do in this case?
try something like this,
use
sum()only when the element is anlistortuple, else simple use the number.improving your solution: