+ 1
Assertion in Python
Why use assertion when you can just create an if statement?
4 RĂ©ponses
+ 5
someone said something along the lines of âif statements catch user errors, assertions are used to catch your ownâ
i dont use them myself and im new to python but it sounds good to me
+ 2
Assertions are basically a debugging tool.
Depending on how your Python code is run, assertions may be ignored completely (basically like comments), and if your code relies on them working, you can probably see how this will lead to trouble.
So to decide what happens in your code, only rely on if and else.
0
You're looking more like a pro...