|
5 | 5 | def rd(): |
6 | 6 | return round(random.random() * 100, 2) |
7 | 7 |
|
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 |
9 | 10 | 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) |
23 | 28 |
|
24 | 29 | #take a name and check the list |
25 | | -def client_check(nme, client_list): |
| 30 | +def client_check(nme, donors): |
26 | 31 | fname, lname = nme.split(' ') |
27 | | - if (lname, fname) in client_list: |
| 32 | + if (lname, fname) in donors: |
28 | 33 | print '{f} {l} is a previous donor.'.format(f=fname, l=lname) |
29 | 34 | return True |
30 | 35 | else: |
31 | 36 | print '{f} {l} is a not a previous donor.'.format(f=fname, l=lname) |
32 | 37 | return False |
33 | 38 |
|
34 | | -res=client_check('Annie Askew', client_list) |
| 39 | +res=client_check('Annie Askew', donors) |
0 commit comments