pyython assert code example
Example 1: assert syntax python
assert <condition>,<error message>
#The assert condition must always be True, else it will stop execution and return the error message in the second argument
assert 1==2 , "Not True" #returns 'Not True' as Assertion Error.
Example 2: assert python 3
# Simple asserting thing, run it by using pytest or something
# If you don't know how to run pytest, then go learn it.
def test_math():
assert(1 + 1 == 2)
# Another way to test it (without pytest) is:
# You could just run the function to see if it makes an error.
# If it doesn't, it means it was fine, if it does, it means there's an error.
# But then again, using pytest or something is much easier and saves time.
# So try to use testing applications instead of running the function to see.