Basically i have this code, and i need a specific output where i state the winner and his number of votes. I seem to have everything down with finding the max value but not it's key counterpart. The error is in my second to last output. Let me know what you guys think, it's probably an easy fix and thank you!!!
print()
print()
print()
import sys
fo = open(sys.argv[1], "r")
dic = {}
count = 0
winner = 0
print("Candidates".center(15), "Votes".rjust(10), "Percent".rjust(10))
print("==========".center(15), "=====".rjust(10), "=======".rjust(10))
for line in fo:
line = line[:-1]
x = line.split(" ")
names = (x[0]) + " " + (x[1])
votes = int(x[2]) + int(x[3]) + int(x[4]) + int(x[5])
dic[names] = votes
count = votes + count
if winner < votes:
winner = votes
for i in dic.keys():
percent = int((dic[i]/count)*100.00)
print (i.center(15),str(dic[i]).center(15),str(percent)+"%")
#Loop through every kid and find percentage,
print()
print("The winner is", "" , "with", winner, "votes!")
print()
print("Total votes polled:", count)
print()
print()
print()