input: Write a function to identify and fix any bugs in the given Python code. The function should take a list as input and return the sum of all elements in the list. If the input list is empty, the function should return 0.
  assert sum_list([1, 2, 3])==6
  assert sum_list([-1, -2, -3])==-6
  assert sum_list([0])==0
  assert sum_list([])==0
output: def sum_list(lst):
      if not lst:
          return 0
      return sum(lst)