<jupyter_start><jupyter_text>USING:     TRY, EXCEPT, & FINALLY<jupyter_code>### Create a list
sales = [6212, 717, 8216, 9218, 4520, 7856, 4312]<jupyter_output><empty_output><jupyter_text>TRY SOMETHING THAT DOESN'T WORK<jupyter_code># Try to add a list of integers and a string, if you get an error print out end program:
try:
    sales + 'A string of characters.'
except Exception as e:
    print('Oh No! We have an Error:', e)
finally:
    print('End Program')<jupyter_output>Oh No! We have an Error: can only concatenate list (not &quot;str&quot;) to list
End Program<jupyter_text>TRY SOMETHING THAT WORKS<jupyter_code># Try to print sales, print out the result & end program, if you get an error, print out error & end program:
try:
    print('Wow! It''s Worked!', sales)
# If you get an error, set the error as 'e',
except Exception as e:
    print('Error:', e)
finally:
    print('End program')<jupyter_output>Wow! Its Worked! [6212, 717, 8216, 9218, 4520, 7856, 4312]
End program
{'fraction_non_alphanumeric': 0.11370558375634518, 'fraction_numerical': 0.05482233502538071, 'mean_word_length': 4.9397590361445785, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '256403', 'license': 'Apache-2.0', 'n_tokens_mistral': 403, 'n_tokens_neox': 354, 'n_words': 131, 'path': 'Using_try_except_finally.ipynb', 'repo_name': 'MaiaNgo/python-best-practices', 'size': '985'}