Python Function Inside Array Methods