Quick actions

cmd+k|ctrl+k

Navigation

Languages

pat 02

Snippet info

Language

Python

Visibility

public

Author

patrickwong928

Created

2026-06-24T11:49:41.973938Z

Updated

2026-06-24T11:55:57.020485Z

# assert exp, exp     raise with express condition
def a():
    print("I am inside function a")
    return f'assert triggered : x is now {x}'
def b():
    print("I am inside function b")
    return False
try :
    x = 10
    y = 1
    result =x/y
#    assert b(), a()
    assert x != 10, f'assert triggered : x is now {x}'
    if x == 1:
        raise
except AssertionError as msg:
    print(msg)
except RuntimeError:
    print("x == 1")
except ZeroDivisionError:
    print("wrong data and error triggered")
except TypeError as msg:
    print(msg)
else:
    print("data are fine !")
    print(result)
finally :
    print("file closing....")
INFO