def addlist(list): """ Add lists of lists, recursively the result is global """ global add for item in list: if type(item) is list: # If item type is list addlist(item) else: add += item add = 0 addlist([[1, 2], [3, 4, 5], 6]) print add # 21