Solution Exercise 18

Define a function sum() and a function multiply() that sums and multiplies (respectively) all the numbers in a list of numbers. For example, sum([1, 2, 3, 4]) should return 10, and multiply([1, 2, 3, 4]) should return 24.

def sum(inList):
    result = 0
    for i in inList:
        result += i
    return result

def multiply(inList):
    product = 1 #Don't use 0 here or your result will always be 0
    for i in inList:
        product *= i
    return product

def main():
    print(sum([1,2,3,4]))
    print(multiply([1,2,3,4]))
    
if __name__ == '__main__':
    main()