traceback (most recent call last)file ""line in exceptionthis is the error message in "loggingon page you'll learn how to use the logging modulewhich is more effective than simply writing this error information to text files assertions an assertion is sanity check to make sure your code isn' doing something obviously wrong these sanity checks are performed by assert statements if the sanity check failsthen an assertionerror exception is raised in codean assert statement consists of the followingthe assert keyword condition (that isan expression that evaluates to true or falsea comma string to display when the condition is false in plain englishan assert statement says" assert that the condition holds trueand if notthere is bug somewhereso immediately stop the program for exampleenter the following into the interactive shellages [ ages sort(ages [ assert ages[ <ages[- assert that the first age is <the last age the assert statement here asserts that the first item in ages should be less than or equal to the last one this is sanity checkif the code in sort(is bug-free and did its jobthen the assertion would be true because the ages[ <ages[- expression evaluates to truethe assert statement does nothing howeverlet' pretend we had bug in our code say we accidentally called the reverse(list method instead of the sort(list method when we enter the following in the interactive shellthe assert statement raises an assertionerrorages [ ages reverse(ages [ assert ages[ <ages[- assert that the first age is <the last age debugging