LearnPy Hub
← Async Basics problems
Medium

Retry a Flaky Call

A coroutine flaky(attempt) fails (raises ConnectionError) until attempt reaches the input number k, then returns ok. Retry up to 5 attempts, printing attempt i failed for failures, then the result or gave up.

Input

One integer k ≥ 1.

Output

Lines.

Sample 1

Input
1
Output
ok

Sample 2

Input
3
Output
attempt 1 failed
attempt 2 failed
ok
solution.py
Output appears here
Retry a Flaky Call · Python practice problem · LearnPy Hub