Question:

Raise Assertion error when trying to verify that every number in the list [2,4,6,8,1] is even.

Use “assert expression” to make assertion

Program:

Explanation:

The Assert Statement: When python encounters an assert statement, Python evaluates the accompanying expression, which is hopefully true. If the expression is false, Python raises an AssertionError exception. 

Output:

Do share your feedback in comments to help us adding more programs like this.

Checkout more Python Programs

Click here

Leave a Reply