5,321
edits
Line 308: | Line 308: | ||
See [https://docs.python.org/3/library/exceptions.html https://docs.python.org/3/library/exceptions.html] | See [https://docs.python.org/3/library/exceptions.html https://docs.python.org/3/library/exceptions.html] | ||
;Try Catch | ;Raising | ||
<syntaxhighlight lang="python"> | |||
raise ValueError("You have bad inputs") | |||
assert 1=1, "Something is very wrong if 1!=1" | |||
</syntaxhighlight> | |||
;Try Catch/Except | |||
<syntaxhighlight lang="python> | <syntaxhighlight lang="python> | ||
try: | try: |