Skip to content

Commit 6d0c637

Browse files
author
anastomose
committed
Added name list function to mailroom
1 parent d9959a0 commit 6d0c637

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

‎Students/ebuer/session_03/mailroom.py‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,35 @@
55
def rd():
66
return round(random.random() * 100, 2)
77

8-
#this may be a bad idea but we will see, a list of tuples for clients
8+
#this may be a bad idea but we will see
9+
#a list of tuples for donors and donations
910
client_list = [
10-
(('Askew', 'Anne'), (rd(), rd(), rd())),
11-
(('Bocher', 'Joan'), (rd(), rd())),
12-
(('Clarkson', 'Jeremy'), (rd())),
13-
(('Hamont', 'Matthew'), (rd(), rd(), rd())),
14-
(('May', 'James'), (rd(), rd())),
15-
(('Parris', 'George van')] (rd(), rd(), rd()))]
16-
17-
18-
19-
20-
21-
22-
11+
(('Askew', 'Anne'), (87.50, 100, 200)),
12+
(('Bocher', 'Joan'), (25, 43.27)),
13+
(('Clarkson', 'Jeremy'), (10.03)),
14+
(('Hamont', 'Matthew'), (1000, 250, 5)),
15+
(('May', 'James'), (30, 75)),
16+
(('Parris', 'George van'), (25, 35, 45))]
17+
18+
#make a name list and a money list
19+
def list_maker(client_list):
20+
donors = []
21+
donations = []
22+
for person in client_list:
23+
donors.append(person[0])
24+
donations.append(person[1])
25+
return donors, donations
26+
27+
donors, donations = list_maker(client_list)
2328

2429
#take a name and check the list
25-
def client_check(nme, client_list):
30+
def client_check(nme, donors):
2631
fname, lname = nme.split(' ')
27-
if (lname, fname) in client_list:
32+
if (lname, fname) in donors:
2833
print '{f} {l} is a previous donor.'.format(f=fname, l=lname)
2934
return True
3035
else:
3136
print '{f} {l} is a not a previous donor.'.format(f=fname, l=lname)
3237
return False
3338

34-
res=client_check('Annie Askew', client_list)
39+
res=client_check('Annie Askew', donors)

0 commit comments

Comments
 (0)