+ 1

What is assert function?

what is it? may i know where and how to use it?

6th Nov 2017, 6:00 AM
Solehah Mohd Hamid
Solehah Mohd Hamid - avatar
2 Réponses
+ 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
6th Nov 2017, 6:07 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Thank you for the answer 😊
6th Nov 2017, 6:15 AM
Solehah Mohd Hamid
Solehah Mohd Hamid - avatar