@@ -32,20 +32,17 @@ def get_donation():
3232
3333def in_dbase (i_name , tar_dbase ):
3434 """ Check if name is in dbase and return boolean """
35- # print 'checking if %s is in dbase' % i_name
36- # print len(tar_dbase)-1
37- # print len(tar_dbase)
38- # for i in range(len(tar_dbase)-1):
3935 for i in range (len (tar_dbase )):
40- # print i, i_name in tar_dbase[i]
4136 if i_name in tar_dbase [i ]:
4237 return True
4338 return False
4439
40+
4541def print_email (p_name , p_donation ):
4642 """ Print thank you not for donation from p_name """
4743 print 'Dear %s, Thanks so much for your generous donation of $%s. It is greatly appreciated!' % (p_name , p_donation )
4844
45+
4946def app_record (app_name , app_dbase ):
5047 """ Append an existing donor record """
5148 for i in range (len (app_dbase )):
@@ -55,15 +52,14 @@ def app_record(app_name, app_dbase):
5552 app_dbase [i ][1 ] += int (app_donation )
5653 print_email (app_name , app_donation )
5754 break
58- # print app_dbase
55+
5956
6057def add_record (add_name , add_dbase ):
6158 """ Add new donor to database """
6259 add_donation = get_donation ()
6360 new = [add_name , int (add_donation ), add_donation ]
6461 add_dbase .append (new )
6562 print_email (add_name , add_donation )
66- # print '--in add_record--', add_dbase
6763
6864
6965def thank_you (dbase ):
@@ -77,22 +73,19 @@ def thank_you(dbase):
7773 else :
7874 for i in range (len (dbase )):
7975 print dbase [i ][0 ]
80-
8176 if in_dbase (name , dbase ):
82- # print '%s is in the dbase' % name
8377 app_record (name , dbase )
8478 else :
85- # print '%s is not in the dbase' % name
8679 add_record (name , dbase )
87- # print 'in thank_you, returning from add_record--', dbase
80+
8881
8982def sum_element (key_dbase ):
9083 """set key for sorting on sum element of data structure"""
9184 return key_dbase [1 ]
9285
86+
9387def mk_report (rep_dbase ):
9488 """ Create a sorted list of donors"""
95-
9689 print 'Donor Name\t \t \t Total Donations\t # of Donations\t \t Average Donation'
9790 rep_dbase .sort (key = sum_element )
9891 for j in range (len (rep_dbase )):
@@ -111,9 +104,6 @@ def mk_report(rep_dbase):
111104 break
112105 elif answer == "1" :
113106 thank_you (donor )
114- # print '--in main--, after thank_you returns', donor
115107 else :
116108 mk_report (donor )
117- print "Exiting"
118-
119-
109+ print "Exiting"
0 commit comments