input: Write a function to compute the average salary of people over a given range of numbers from the dataset 'salary.csv'. Return the computed average salary. If the file is empty or salaries cannot be converted to integers, return None.
  def get_average_salary(filename):
    total = 0
    count = 0
  
    with open(filename, 'r') as csvfile:
      csvreader = csv.reader(csvfile)
      next(csvreader) # skip header
  
      # loop through the CSV rows
      for row in csvreader:
        try:
          total += int(row[1])
          count += 1
        except (ValueError, IndexError):
          return None
    
    if count == 0:
      return None
    
    return total/count
  
  assert get_average_salary('salary.csv')==2000.0
  assert get_average_salary('empty.csv')==None
  assert get_average_salary('corrupted.csv')==None
output: 
  def get_average_salary(filename):
    total = 0
    count = 0
  
    try:
      with open(filename, 'r') as csvfile:
        csvreader = csv.reader(csvfile)
        next(csvreader) # skip header
  
        for row in csvreader:
          try:
            total += int(row[1])
            count += 1
          except (ValueError, IndexError):
            return None
    except FileNotFoundError:
      return None
    
    if count == 0:
      return None
    
    return total/count
  