DEV Community

Cover image for "assertion"   (python3)
francnstein
francnstein

Posted on

1 1

"assertion" (python3)

Assertions

An assertion is a sanity-check that you can turn on or turn off when you have finished testing the program.
An expression is tested, and if the result comes up false, an exception is raised.
Assertions are carried out through use of the assert statement.

print(1)
assert 2 + 2 == 4
print(2)
assert 1 + 1 == 3
print(3)

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay