file ""line in assertionerror unlike exceptionsyour code should not handle assert statements with try and exceptif an assert failsyour program should crash by "failing fastlike thisyou shorten the time between the original cause of the bug and when you first notice the bug this will reduce the amount of code you will have to check before finding the bug' cause assertions are for programmer errorsnot user errors assertions should only fail while the program is under developmenta user should never see an assertion error in finished program for errors that your program can run into as normal part of its operation (such as file not being found or the user entering invalid data)raise an exception instead of detecting it with an assert statement you shouldn' use assert statements in place of raising exceptionsbecause users can choose to turn off assertions if you run python script with python - myscript py instead of python myscript pypython will skip assert statements users might disable assertions when they're developing program and need to run it in production setting that requires peak performance (thoughin many casesthey'll leave assertions enabled even then assertions also aren' replacement for comprehensive testing for instanceif the previous ages example was set to [ ]then the assert ages[ <ages[- assertion wouldn' notice that the list was unsortedbecause it just happened to have first age that was less than or equal to the last agewhich is the only thing the assertion checked for using an assertion in traffic light simulation say you're building traffic light simulation program the data structure representing the stoplights at an intersection is dictionary with keys 'nsand 'ew'for the stoplights facing north-south and east-westrespectively the values at these keys will be one of the strings 'green''yellow'or 'redthe code would look something like thismarket_ nd {'ns''green''ew''red'mission_ th {'ns''red''ew''green'these two variables will be for the intersections of market street and nd streetand mission street and th street to start the projectyou want to write switchlights(functionwhich will take an intersection dictionary as an argument and switch the lights at firstyou might think that switchlights(should simply switch each light to the next color in the sequenceany 'greenvalues should change to 'yellow''yellowvalues should change to 'red'and 'redvalues should change to 'greenthe code to implement this idea might look like thisdef switchlights(stoplight)for key in stoplight keys()