input: Write a function to calculate the sum of a list of numbers. If the list is empty, return 0.
  
  def sum_list(arr):
      """Calculates the sum of a list of numbers.
      
      Args:
          arr (list): List of numbers.
          
      Returns:
          int: Sum of list elements. If the list is empty, returns 0.
      """
      sum = 0
      for num in arr:
          sum += num
      if len(arr) == 0:
          return 0
      return sum
  
  assert sum_list([1, 2, 3, 4, 5])==15
  assert sum_list([10, 20, 30])==60
  assert sum_list([0, -1, 1])==0
  assert sum_list([7])==7
  assert sum_list([])==0
output: def sum_list(arr):
      if not arr:
          return 0
      return sum(arr)