Dec-19-2022, 05:24 PM
got the answer,
assert a and not print("sucess"),"failure"
If 'a' is True, then python executes the next expression 'not print("sucess")'.
print("success") prints "success", and then returns None. not None is True(print(not None)), so the assert passes.
If 'a' is False, then python doesn't bother about executing the second part and the assert just fails.
When an assert fails it prints the message after the comma which is "failure"
assert a and not print("sucess"),"failure"
If 'a' is True, then python executes the next expression 'not print("sucess")'.
print("success") prints "success", and then returns None. not None is True(print(not None)), so the assert passes.
If 'a' is False, then python doesn't bother about executing the second part and the assert just fails.
When an assert fails it prints the message after the comma which is "failure"