202k views
4 votes
def retry(operation, attempts): for n in range(attempts): if operation(): print("Attempt " + str(n) + " succeeded") ___ else: print("Attempt " + str(n) + " failed") retry(create_user, 3) retry(stop_service, 5)

1 Answer

1 vote

Answer:

Following are the missing code to this question:

break;

Step-by-step explanation:

In the given python code, a method "retry" is defined, that accepts two-variable, that is "operation and attempts" in its parameters, inside the method a for loop is defined that uses the n variable to holds attempt values and define the conditional statement.

  • Inside if block, it checks if the operation value is true, it will print a successful attempts values and break the condition, otherwise it will goto else block.
  • In the else block, it will print failed attempts values.
User Jany
by
7.2k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.