diff --git a/docs/cheatsheet/debugging.md b/docs/cheatsheet/debugging.md index b4edf43e..fef6691e 100644 --- a/docs/cheatsheet/debugging.md +++ b/docs/cheatsheet/debugging.md @@ -138,7 +138,7 @@ Say you wrote a function to calculate the factorial of a number. In mathematics, >>> def factorial(n): ... logging.debug('Start of factorial(%s)' % (n)) ... total = 1 -... for i in range(1, n + 1): +... for i in range(0, n + 1): ... total *= i ... logging.debug('i is ' + str(i) + ', total is ' + str(total)) ... logging.debug('End of factorial(%s)' % (n)) @@ -159,6 +159,8 @@ Say you wrote a function to calculate the factorial of a number. In mathematics, # 2015-05-23 16:20:12,684 - DEBUG - End of program ``` +Using the log output, we can see that `for i in range(0, n + 1)` should have been `for i in range(1, n + 1)`. + ## Logging Levels Logging levels provide a way to categorize your log messages by importance. There are five logging levels, described in Table 10-1 from least to most important. Messages can be logged at each level using a different logging function.