-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandling_error.py
More file actions
26 lines (19 loc) · 842 Bytes
/
handling_error.py
File metadata and controls
26 lines (19 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def party_planner(cookies, people):
leftovers = None
num_each = None
try:
num_each = cookies // people
leftovers = cookies % people
except:
print("Not a valid input");
return(num_each, leftovers)
# The main code block is below; do not edit this
lets_party = 'y'
while lets_party == 'y':
cookies = int(input("How many cookies are you baking? "))
people = int(input("How many people are attending? "))
cookies_each, leftovers = party_planner(cookies, people)
if cookies_each: # if cookies_each is not None
message = "\nLet's party! We'll have {} people attending, they'll each get to eat {} cookies, and we'll have {} left over."
print(message.format(people, cookies_each, leftovers))
lets_party = input("\nWould you like to party more? (y or n) ")