Snippets Collections
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)
def factorial(n):
    result = 1
    for x in range(0,10):
        result = result * x
    return x

for n in range(0,10):
  print(n, n*factorial(n+1))
star

Tue Feb 06 2024 06:22:51 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/60689743/factorial-code-does-not-return-product-of-integer-and-all-integers-before-it

#python #forloops

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension