define a function that takes a list of numbers as an argument and returns the sum of the numbers in the list. in python

main.py
def sum_list(numbers):
    """
    this function takes a list of numbers as input and returns the sum of the numbers
    """
    total_sum = sum(numbers)
    return total_sum
175 chars
7 lines

We define a function called sum_list that takes in numbers as input, which is a list of numbers. sum function is then used to calculate the total sum of the numbers in the list. Finally, the sum is returned as output.

gistlibby LogSnag