repl.it
@RoselyAlvaradoV/

balot counts

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
presi_count = {"McCain_1": 10, 'McCain_2': 3, 'Obama_1': 19, 'Obama_2': 2, 'McCain_3': 7, 'McCain_4': 2, 'Obama_3': 6, 'Obama_4': 10, "McCain_5": 11, 'McCain_6': 5 , 'Obama_5': 3, 'Obama': 12, 'McCain': 13 } #dictonary of all the votes 
Mcount = list() #list set up 
Ocount = list() #list set up 
for key,value in presi_count.items(): 
  #Goes through every iteam in Presi_count and adds each valueto the appropriate list 
  if "McCain" in key: #finds Mccain in the iteam
    Mcount.append(value)
  elif "Obama" in key:  #finds Obama in the iteam
    Ocount.append(value)
print("McCain total: " + str(sum(Mcount))) #sums list
print("Obama total: " + str(sum(Ocount))) #sums list