input: Write a function that calculates the average of a list of numbers. If the input list is empty, the function should return 0. Provide the function header, test cases, and the expected outputs for each test case.
  
  def avg_list(lst):
   sum = 0
   count = 0
   for i in lst:
    sum += i
    count += 1
   if count == 0:
    return 0
   avg = sum / count
   return avg
  
  assert avg_list([1, 2, 3, 4, 5]) == 3.0
  assert avg_list([10, 20, 30, 40, 50]) == 30.0
  assert avg_list([1]) == 1.0
  assert avg_list([-1, 0, 1]) == 0.0
  assert avg_list([]) == 0
output: def avg_list(lst):
      if not lst:
          return 0
      return sum(lst) / len(lst)