Write a Python function to calculate the sum of all numbers in a list.
[1, 2, 3, 4, 5, 6, 7, 8, 9]
def sum_nums(nums):
  sum = 0
  for num in nums:
    sum += num
  return sum

sum_nums([1, 2, 3, 4, 5, 6, 7, 8, 9]) # returns 45