5. Question 5 The retry function tries to execute an operation that might fail, it retries the operation for a number of attempts. Currently the code will keep executing the function even if it succeeds. Fill in the blank so the code stops trying after the operation succeeded. · GitHub

PHOTO EMBED

Tue Feb 06 2024 06:34:10 GMT+0000 (Coordinated Universal Time)

Saved by @Mad_Hatter #python #forloops

def retry(operation, attempts):
  for n in range(attempts):
    if operation():
      print("Attempt " + str(n) + " succeeded")
      break
    else:
      print("Attempt " + str(n) + " failed")

retry(create_user, 3)
retry(stop_service, 5)
content_copyCOPY

google python crash course

https://gist.github.com/Kimjunkuk/393a2b97d2d24d490d7d64c77173606e