PIXELBANKv9.1.0
Menu

Classify an Error as Retryable

Problem Statement

Decide whether a failed tool call should be retried based on its HTTP-style status code. Transient failures are worth retrying; client errors are not.

Background

By convention, 429 (rate limited) and any 5xx (server error) are retryable. 4xx other than 429 are client errors and are not retryable. Anything below 400 is a success and needs no retry.

Your Task

Implement:

def is_retryable(status):

Return True if status is 429 or in [500, 599], else False.

Input Format

  • status (int): the status code.

Output Format

  • A boolean.

Sample

print(is_retryable(503))

Output:

True

Example:

Input:
print(is_retryable(503))
Output:
True
Reasoning:
  • The input status code is 503503, which is passed to the classification logic to determine if it represents a transient failure.
  • The function first checks if the status is exactly 429429 (rate limited); since 503≠429503 \neq 429, this condition evaluates to false.
  • Next, it checks if the status falls within the server error range [500,599][500, 599]; since 500≤503≤599500 \le 503 \le 599, this condition evaluates to true.
  • Because the status satisfies the server error criterion, the overall retryability check returns true, indicating the call should be retried.
  • The final output is True

Constraints:

  • Retryable: status == 429 or 500 <= status <= 599.
  • All other codes are non-retryable.
  • Return a bool.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Classify an Error as Retryable - Easy | PixelBank