
Christopher S. answered 05/09/19
Christo: Online programming and Computer Literacy tutor
The assert statement is used as a way to test if your code is getting results that it should not be getting. All it does is check what is provided for it, and if True, nothing happens, but if False, it throws some kind of exception. This exception defaults to AssertionError, but can be changed in the assertion itself.
An example of a default assertion that will throw AssertionError:
An example of an assertion that will throw a custom error
This has a variety of uses from testing if functions are receiving/producing the correct results in test cases, or tracking down the root of an error.
So to answer your question directly, the assert statement doesn't "do" any thing for the program itself, at least in the same way that an if then statement compares something, but it does make for a useful testing tool allowing for easier automatic testing.