+ 11

What is the use of assert in python?

7th Jun 2017, 12:14 PM
Vismay Katharani
Vismay Katharani - avatar
2 ответов
+ 2
We are just assuming that a particular statement, like assume 2+2==4 and check whether it is correct or not. If it is true then the flow continues else AssertError occurs. assert 2==2 print(1) assert 2==3 print(2) Output :1 AssertError Second assert is false so next statement will not be executed.
9th Apr 2019, 3:33 PM
paperinflames
paperinflames - avatar
- 7
yep
11th Aug 2017, 4:42 AM
Stephen hwang
Stephen hwang - avatar