Complete the code to retry a function call once if it fails.
try: result = perform_task() except Exception: result = [1]()
Complete the code to fallback to an alternative function if the main task fails.
try: result = main_task() except Exception: result = [1]()
Fix the error in the retry loop to stop after 3 attempts.
attempts = 0 while attempts < 3: try: result = task() break except Exception: attempts [1] 1
Fill both blanks to implement retry with fallback after 3 failed attempts.
attempts = 0 while attempts < 3: try: result = [1]() break except Exception: attempts [2] 1 else: result = fallback()
Fill all three blanks to log errors, retry twice, then fallback.
import logging attempts = 0 while attempts < [1]: try: result = [2]() break except Exception as e: logging.error(str(e)) attempts [3] 1 else: result = fallback()
