Try Except and Else block in Python

Try Except is a syntax for error handling in Python. Else block is optional and is executed only if program runs successfully without encountering any exception.

a=40
b=10
try:
    c=a/b
    print(c)
except:
    print("Cant divide by 0")
else:
    print("Success")

    

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes