Why do we use assert in Python 3? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок

Why do we use assert in Python 3?

Please anyone answer for this

8th Mar 2020, 2:20 AM
Rock_Arul - avatar
2 ответов
+ 2
assert is typically used in unit testing, and it can be used for debugging, making sure that an unexpected condition doesn't cause any bugs in your program. It should not be used for validation of data or user input, because assert can be disabled globally in the python interpreter. Read this for more info. https://dbader.org/blog/python-assert-tutorial
8th Mar 2020, 7:02 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Thank you for ur explanation
3rd Apr 2020, 2:10 PM
Rock_Arul - avatar