<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expire(app, sandbox, exit=True):
 """Expire hits for an experiment id."""

    success = []
    failures = []
    service = _mturk_service_from_config(sandbox)
    hits = _current_hits(service, app)
    for hit in hits:
        hit_id = hit["id"]
        try:
            service.expire_hit(hit_id)
            success.append(hit_id)
        except MTurkServiceException:
            failures.append(hit_id)
    out = Output()
    if success:
        out.log("Expired {} hits: {}".format(len(success), ", ".join(success)))
    if failures:
        out.log(
            "Could not expire {} hits: {}".format(len(failures), ", ".join(failures))
        )
    if not success and not failures:
        out.log("No hits found for this application.")
        if not sandbox:
            out.log(
                "If this experiment was run in the MTurk sandbox, use: "
                "`dallinger expire --sandbox --app {}`".format(app)
            )
    if exit and not success:
        sys.exit(1)