Skip to content

Commit 763d061

Browse files
author
meshmote
committed
Fixed get_donation data verification, re-wrote main to use in_dbase for add vs. append
1 parent 69a5ba7 commit 763d061

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎Students/RPerkins/session03/mailroom.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ def get_input():
2121
return answer
2222

2323

24+
def get_donation():
25+
""" Prompt for donation amount, validate input, return amount"""
26+
d = u' '
27+
while not d.isnumeric():
28+
new_d = raw_input("Enter donation amount (must be numeric)-->")
29+
d = unicode(new_d)
30+
return str(d)
31+
32+
33+
def in_dbase(name, dbase):
34+
""" Check if name is in dbase and return boolean """
35+
for i in range(len(dbase)-1):
36+
if name not in dbase[i]:
37+
38+
def add_record(name, dbase):
39+
""" Call get_donation and add new donor to database with result """
40+
new = [name, get_donation()]
41+
dbase.append(new)
42+
print dbase
43+
44+
def app_record(name, dbase):
45+
""" Append an existing record with new donations """
46+
47+
2448
def thank_you(dbase):
2549
""" Find or create a donor, add new donation, and return a thank you note"""
2650
name = 'list'
@@ -33,6 +57,15 @@ def thank_you(dbase):
3357
for i in range(len(dbase)-1):
3458
print dbase[i][0]
3559

60+
if in_dbase(name, dbase):
61+
app_record(name, dbase)
62+
else:
63+
add_record(name, dbase)
64+
65+
66+
67+
68+
3669

3770

3871
def mk_report():

0 commit comments

Comments
 (0)