Skip to content
Prev Previous commit
Next Next commit
completed exceptions lab, created working file for exceptions lab
  • Loading branch information
sgrees committed Feb 22, 2016
commit 9d25e3a3753a597b025ea52cc2e32b8ed4ff5ff6
8 changes: 8 additions & 0 deletions students/susanRees/session05/comprehensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
feast = ['lambs', 'sloths', 'orangutans', 'breakfast cereals', 'fruit bats']
comprehension = [delicacy.capitalize() for delicacy in feast]
print(comprehension[0])
print(comprehension[2])

comp = [delicacy for delicacy in feast if len(delicacy) > 6]
print(len(feast))
print(len(comp))
12 changes: 12 additions & 0 deletions students/susanRees/session05/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Create a wrapper function, safe_input()
# returns None rather rather than raising the exceptions EOFError or KeyboardInterrupt
# when user enters ^C for Keyboard Interrupt, or ^D (^Z on Windows) for End Of File.

def safe_input():
try:
input("Type something here")
except (EOFError, KeyboardInterrupt):
return None
else:
print("Thanks.")
safe_input()