diff options
Diffstat (limited to 'notebooks/exception_handling.py')
-rw-r--r-- | notebooks/exception_handling.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/notebooks/exception_handling.py b/notebooks/exception_handling.py new file mode 100644 index 0000000..50bf830 --- /dev/null +++ b/notebooks/exception_handling.py @@ -0,0 +1,34 @@ +# Exception handling +# - programming errors +# - user errors +# TRY +# <statement> +# EXCEPT +# <statement> +# ENDTRY + +def safe_student_open(filename): + try: + sfile = open(filename, 'rb') + sfile.close() + except OSError: + print("wtf is this file man") + +def test_input_integer(): + val = input("sample input: ") + try: + value = int(val) + print(value) + print("It is an integer") + except ValueError: + print("Noooo bro it isn't an integer cmon man get good") +# test_input_integer() + +def integer(num): + try: + b = int(num) + print(b) + print("is integer") + except: + print("not") +safe_student_open("thing.data")p
\ No newline at end of file |