Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

assert keyword in python

The assert keyword is used when debugging code.

The assert keyword lets you test if a condition in your code returns 
True, if not, the program will raise an AssertionError.

You can write a message to be written if the code returns False, check 
the example below.

x = "hello"

#if condition returns False, AssertionError is raised:
assert x == "goodbye", "x should be 'hello'"
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #assert #keyword #python
ADD COMMENT
Topic
Name
7+8 =