Preview:
# coditions may act as guardians, protecting the coe that follows from values that might cause an error
# Ex: factorial() can only take positive integers, n:
def factorial(n):
  if not isintance(n, int):
    print("n has to be an integer!")
    return None
  elif n < 0:
    print("n has to be positive number!")
    return None
  elif n == 0:
    return 1
  else:
    return n * factorial(n-1)  
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