I'm having a difficult time understanding assertions. Can someone please explain assertions to me? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I'm having a difficult time understanding assertions. Can someone please explain assertions to me?

13th Sep 2016, 2:17 PM
DELETED
3 Answers
+ 2
You can use assertions to debug your program. It's a bit like a raise-if-not statement.
13th Sep 2016, 2:52 PM
Zen
Zen - avatar
+ 2
Some times while programing we do not see certain mistakes we make, so assertions are milestones that help us assure we are on the right track. Using them we make sure our program will operate as desired. They serve to show us where and what kind of error happend, so we can fix it.
30th Sep 2016, 2:24 PM
Sefl13
0
Assertion acts pretty much like exception handler but you can place assertion mostly after receiving user input to check if it is valid input,if it is valid then the program will continue otherwise it will terminate and the rest of the lines will not be executed. This will make your program run smoothly and to be perfect.
14th Oct 2016, 6:10 AM
Isack T Nicholaus
Isack T Nicholaus - avatar