Skip to content

Commit 9d25e3a

Browse files
committed
completed exceptions lab, created working file for exceptions lab
1 parent 71f7cc3 commit 9d25e3a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
feast = ['lambs', 'sloths', 'orangutans', 'breakfast cereals', 'fruit bats']
2+
comprehension = [delicacy.capitalize() for delicacy in feast]
3+
print(comprehension[0])
4+
print(comprehension[2])
5+
6+
comp = [delicacy for delicacy in feast if len(delicacy) > 6]
7+
print(len(feast))
8+
print(len(comp))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Create a wrapper function, safe_input()
2+
# returns None rather rather than raising the exceptions EOFError or KeyboardInterrupt
3+
# when user enters ^C for Keyboard Interrupt, or ^D (^Z on Windows) for End Of File.
4+
5+
def safe_input():
6+
try:
7+
input("Type something here")
8+
except (EOFError, KeyboardInterrupt):
9+
return None
10+
else:
11+
print("Thanks.")
12+
safe_input()

0 commit comments

Comments
 (0)