I try to sum a list of nested elements
e.g, numbers=[1,3,5,6,[7,8]] should produce sum=30
numbers=[1,3,5,6,[7,8]]
sum=30
I wrote the following code :
def sum_nest_lst(lst): t=0 for l in lst: if(type(l)==int): t=t+l if(type(l)==list): t=t+sum(l) print(t)