input: Write a function to fix any bugs in the following Python code. To fix the bug, ensure that the function returns the sum of the elements in the list correctly. If the input list is empty, the function should return 0.
  
  def sum_list(list):
      sum_list = 0
      for num in list:
          sum_list += num
      return sum_list
  
  assert sum_list([1, 2, 3, 4])==10
  assert sum_list([-1, 0, 1])==0
  assert sum_list([])==0
  assert sum_list([5])==5
  assert sum_list([-5, 5])==0
output: def sum_list(input_list):
      total_sum = 0
      for num in input_list:
          total_sum += num
      return total_sum