![]() Here the line “ x = 5/0″ in Example 1 above raised a “ ZeroDivisionError” which was caught by our except clause and the print() statement printed the default error message which is “ division by zero” to the standard output. A problem has occurred from the Problematic code: division by zero Running this code will give the output below. Print('A problem has occurred from the Problematic code: ', e) ![]() #Some Problematic code that can produce Exceptions The first and easiest option is to print error messages using a simple print() statement as shown in the example below. Option#1: Using a simple print() statement Let us start with the simplest of the 3, which is using a print() statement. There are 3 ways to print custom error messages in Python. So, let’s begin! Printing Custom Error messages 2 Choosing Parts of Default Error Messages to print
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |