Skip to main content

Posts

Showing posts with the label condition

Python - Use of Assert Keyword

🐍  Assert keyword simply checks if a condition returns true or false. It is a short for writing if statement to check if something is true or false. Syntax assert <condition>, <optional message> Optional message in the syntax is optional. It is displayed in the error when the condition is false. When the condition is false, the code will also not proceed any further. It ends the program there and returns and error with the message, if it is mentioned. Example assert 25%2==0, 'Add 1 to the number'