input: Write a function to calculate the average of a list of numbers in Python. The function should take a list of numbers as input and return the average value as a float. If the list is empty, the function should return 0.
  assert avg_list([2, 4, 6, 8]) == 5.0
  assert avg_list([10, 20, 30, 40]) == 25.0
  assert avg_list([1, 2, 3, 4, 5]) == 3.0
  assert avg_list([3]) == 3.0
  assert avg_list([]) == 0
  
  def avg_list(lst):
      if not lst:
          return 0
      sum = 0
      count = 0
      for i in lst:
          sum += i
          count += 1
      avg = sum / count
      return avg
output: def avg_list(lst):
      if not lst:
          return 0
      return sum(lst) / len(lst)