Skip to content

Instantly share code, notes, and snippets.

@sunbuhui
Created March 27, 2021 03:02
Show Gist options
  • Save sunbuhui/cadf519693e4eab7253750e832ae8310 to your computer and use it in GitHub Desktop.
Save sunbuhui/cadf519693e4eab7253750e832ae8310 to your computer and use it in GitHub Desktop.
Python assert Keyword

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.

assert word.endswith(suffix), "Given word doesn't end with given suffix"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment