Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ROBOMASTER-S1/2fdde9a007387fbfc6afd7a7d6cc4e99 to your computer and use it in GitHub Desktop.
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
# 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