from pythontest.DatabaseConnection import DatabaseConnection def checkServices(db: DatabaseConnection, services: list): alldata = [ route for id in services for route in db.query('service %s route:123,234,345,456' % id) ] result = [ (data['id'], issue) for data in alldata if (issue := checkData(data)) is not None ] return result def checkData(data: dict): result = None if data['id'] % 2 != 0: result = data['name'] + ' is not even' return result