Skip to content

Commit 1a1a287

Browse files
committed
updated mailroom project
1 parent cb42249 commit 1a1a287

File tree

1 file changed

+64
-27
lines changed

1 file changed

+64
-27
lines changed
Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,100 @@
1-
# mailroom
1+
# mailroom script: Writes emails thanking donors for donation amounts and generates report of donations
2+
#
3+
import random
4+
import string
5+
import sys
6+
from collections import Counter
27

3-
#my = dict(name='Chris', 'John', amount='1','2','3')
4-
#my = dict(name='Chris', 'John', amount='1','2','3')
5-
d = {'doner1': 'Chris C', 'doner2': 'John J','doner3': 'Matt M','doner4': 'Luke L','doner5': 'Eli E'}
8+
# Initial Dictionary of doners nd amounts
9+
d = {'Chris C': 200, 'John J': 300, 'Matt M': 400, 'Luke L': 100, 'Eli E': 500}
610
a = {'amount1': 1,'amount2': 2,'amount3': 3,'amount4': 4,'amount5': 5}
711

8-
print("print the doners",d)
9-
print("print the amounts",a)
10-
# prompt for option
12+
#print("The doners are:",d)
13+
#print("print the amounts",a)
1114

12-
13-
#FIZZBUZZ function
15+
# function to get doner and the amount
1416
def donfunc(option,name,amount):
1517
#if thanks you:
1618
if option == 'yes':
1719
#print("print doner",name)
1820
if name == "list":
19-
print("print the list of doners",d)
21+
print("printing the list of doners.... ",d)
2022
don_again = input('Enter full name of doner:')
2123
dname = don_again
22-
if don_again in (d):
23-
print("print the list of doners",d)
24-
else:
25-
d['doner6'] = dname
26-
#print("print the doners",d)
2724
else:
2825
dname = name
29-
d['doner6'] = dname
30-
# amount = input('Enter the donation amount:')
3126

3227
if amount.isdigit() == True:
33-
print("print new amount",amount)
28+
#print("print new amount",amount)
29+
amount = int(amount)
3430
else:
3531
# print("enter a number please:")
3632
amount = input('enter a number please:')
37-
a['amount6'] = amount
38-
print("print the list of doners",d)
39-
print("print the list of amounts",a)
33+
amount = int(amount)
34+
#a['amount6'] = amount
35+
if dname in (d):
36+
d[dname] = d[dname] + amount
37+
else:
38+
d[dname] = amount
39+
#print("print the list of doners",d)
40+
#print("print the list of amounts",a)
4041

4142
#print("Dear %s,\n",%dname)
4243
print('Dear {0},'.format(dname))
43-
print("Thank you for your {0}th donation".format(amount))
44+
print("Thank you for your ${0}.00 donation".format(amount),'\n')
4445
#don = input('Enter full name of doner or list:')
4546

46-
def repfunc():
47+
def repeats(name,comp):
48+
if (name == comp):
49+
match = 1
50+
return match
51+
52+
def repfunc(count,dn):
4753
#if opt2 == 'yes':
54+
#for i, item in enumerate(d):
55+
#print(a)
56+
l = len(d)
57+
#print(l)
58+
#ak = list(a)[i]
59+
#print(ak)
60+
tot = sum(d.values())
61+
#print('total..........',tot)
62+
avg = tot/l
63+
numd = count
64+
n = ('{:s} ${:d}.00 {} ${:06.2f}.00'.format(dn,d[dn],numd,avg))
65+
print(n)
66+
67+
m = repeats(name="temp",comp="temp")
68+
69+
#function to print out the report
70+
def report ():
71+
h = ('Doner Total Donation Count Average Donation')
72+
print(h)
4873
for i, item in enumerate(d):
49-
#print("the %ith item is: %s"%(i, item))
50-
print("the %ith doner is: %s"%(i,d.get(item)))
74+
f = list(d)[i]
75+
cnt = 0
76+
for i in d.keys():
77+
#print('iiiiiii',i)
78+
#print(cnt)
79+
m = repeats(name=f,comp=i)
80+
#print(m)
81+
if m == 1:
82+
cnt = cnt + 1
83+
#print('count........',cnt)
84+
#print("the %ith item is: %s with count %i"%(i, d.get(item),cnt))
85+
ndict = ('{:s}(count:{:d})'.format(f,cnt))
86+
repfunc(count=ndict,dn=f)
87+
5188

5289
opt1 = input('Send a Thank You?:')
5390
opt2= input('Create a Report?:')
5491

5592

5693
if opt1 == 'yes':
5794
don = input('Enter full name of doner or list:')
58-
amou = input('enter the donation number:')
95+
amou = input('enter the donation amount:')
5996
#call the function
6097
donfunc(option=opt1,name=don,amount=amou)
6198
if opt2 == 'yes':
6299
#call the function
63-
repfunc()
100+
report()

0 commit comments

Comments
 (0)