DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

4 ‘Else Clauses’ in Python

4 years ago levelup.gitconnected.com
4 ‘Else Clauses’ in Python

Summary: This is a summary of an article originally published by the source. Read the full original article here →

In Python, we might find else clause in if statement, for, while loops, and try block also. else clause is optional in all these statements.

The try statement specifies exception handlers and/or cleanup code for a group of statements: Syntax:try:In the try block, code is executed and if an exception is raised, control goes to the except clause.

else:else clause is executed if the control flow leaves the try suite, no exception was raised, and no return, continue, or break statement was executed.

Even when a return, break or continue statement is executed in the try suite of a try…

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com