+ 1
What is assert function?
what is it? may i know where and how to use it?
2 Antworten
+ 8
It is a keyword which has to be folowed by a boolean.
If a False condition is met, it raises an AssertionError.
like:
assert 2+3==5 #does nothing
assert 2+4==8 #raises AssertionError
Works well with exception handling which is why it was created
+ 1
Thank you for the answer 😊