Let me explain my problem I am looking to make a program that compares user absences in 2 different tools. The result of their absence is returned in 2 Excel file or in which I make a sum of each absence for each user thanks to a dictionary in python then I compare the 2 dictionary in order to find an error and suddenly the program returns the name of the user for whom the number of absences is not equal. And so I would like to know how to make my program send an email to the user concerned.
Sum of absences :
for row in range(1,253):
id2.append(feuille_2.cell_value(row, 2))
absence2.append(float(feuille_2.cell_value(row, 9)))
result = {}
for name in set(id2):
result[name] = 0
for i in range(len(id2)):
hours = float(absence2[i])
name = id2[i]
result[name] += hours
for name, hours in result.items():
print(name + ":\t" + str(hours))
id4 = [id1]
absence = []
for row in range(1,361):
absence.append(feuille_1.cell_value(row, 10))
id4.append(id1)
print(absence)
result2 = {}
for name2 in set(id4):
result2[name2] = 0
for i in range(len(id4)):
hours2 = absence[i]
name2 = id4[i]
result2[name2] += hours2
print(result2)
Comparaison of two dictionaries :
print("Seulement sur Sugar:", ", ".join(set(result).difference(result2)))
print("Seulement sur Chrnos:", ", ".join(set(result2).difference(result)))
for key in set(result).intersection(result2):
if result[key]!=result2[key]:
print("%s n'a pas declarer ses congée"% (key))
And I want help i want a function who send an email to each user concerned. After the comparaison