Create a function in Python that takes a list as an argument and returns the sum of all the numbers in the list.
[1, 2, 3, 4]
def sum_list(nums):
    total = 0
    for num in nums:
        total += num
    return total