brightlightkim 2022. 7. 15. 10:38

# Tip: You can use the type(element) function to check whether an item
# is a list or an integer.
def productSum(array):
    # Write your code here.
    return productHelper(array, 1)

# m: multiply value
def productHelper(array, m):
    sum = 0
    for x in array:
        if type(x) == list:
            sum += (m+1) * productHelper(x, m+1)
        else:
            sum += x
    return sum