Quick actions

cmd+k|ctrl+k

Navigation

Languages

try, raise, assert, except 22/5

Snippet info

Language

Python

Visibility

public

Author

tonyngswell

Created

2026-05-21T13:48:46.600624Z

Updated

2026-05-21T13:48:46.600624Z

try:
    x=1
    y=x+1
    if y==2:
        raise
except:
    print("y is 2")
    
def a():
    print("function a")
    return False
try:
    x=1
    y=x+1
    if y==2:
        assert a(), 'assertion error' #assert exp1, exp2
except AssertionError as msgg:
    print(msgg)
INFO