Created
March 7, 2023 05:18
-
-
Save ROBOMASTER-S1/2fdde9a007387fbfc6afd7a7d6cc4e99 to your computer and use it in GitHub Desktop.
Try and Except Skeletal Structure Python Program Example: Created by Joseph C. Richardson
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by Joseph C. Richardson, GitHub.com | |
# Here is a basic, skeletal structure of a Try: and Except: block. | |
# The 'Pass' statement ignores any empty code blocks, which are | |
# not used for now. In this case, only the skeletal structure of the | |
# program is clearly shown. Note: you do not need to invoke the | |
# 'finally' statement into try: and Except: blocks, but they can be | |
# quite handy when you want to show any output on the screen, | |
# no matter the outcome of the program's execution/run. | |
try: | |
pass | |
except Exception: | |
pass | |
finally: | |
pass | |
# Here is our same try: and except: skeletal structure, but this time | |
# it has some beef inside the code bocks. | |
try: | |
num=int(input('Type a Number: ').strip()) | |
except ValueError: | |
print('Sorry! Numbers only please.') | |
finally: | |
print('finally always executes no matter the outcome.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment