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)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter