Assertions : assert « Statement « Python Tutorial






age = 10 
assert 0 < age < 100 
age = -1 
assert 0 < age < 100 

assert 1 == 1
assert 2 + 2 == 2 * 2
assert len(['my list', 12]) < 10
assert range(3) == [0, 1, 2]
assert 1 == 0
assert 1 == 0, 'One does not equal zero silly!'








3.17.assert
3.17.1.check whether a condition is true and raises an AssertionError (optionally with a supplied error message) if it isn't.
3.17.2.Assertions