The process of identifying and fixing the bug is called debugging.very common way of debugging is to use print() statement. but the problem with the print() statement is after fixing the bug, compulsory we have to delete the extra added print() statement, otherwise these will be executed at runtime which creates performance problems and disturb console output.

To overcome this problem we should go for assert statement. the main advantage of assert statement over print() statement is after fixing bug we are not required to delete assert statement. based on our requirement we can enable or disable assert statements.

Hence the main purpose of assertion is to perform debugging. usully we can perform debugging either in development or in test environments but not in production environment. hence assertion concept is applicable is only for dev and test environments but not for production environment.


Report an error