i get an error message when converting str to int or float : line 39, in main votes_rate = round(flo

i get an error message when converting str to int or float : line 39, in main
votes_rate = round(float(ballots) / float(elig_votes) *100,2)
ValueError: could not convert string to float: ‘In 1964, 85.15% ofeligible voters registered, and 68.73% voted.’ the cod is : # main
def main():
print(‘ The voter participation data from a file and processes thatdata in several different ways’)
print()
# info year = 0 # num of years
year_under_60 = 0 # years under 60%
reg = 0 # registers votes
ballot = 0 # cast ballots
vote_more_80 = 0 # votes more than 80%
  
# input
file_name = input(‘Enter the name of the file you want to read:’) # open file
read_file = open(file_name, ‘r’)
report_name = ‘REPORT-‘ + file_name
report = open(report_name, ‘w’) line = read_file.readline().rstrip() # loop while line != “”: year = (line)
elig_votes = (read_file.readline().rstrip())
reg_votes = (read_file.readline().rstrip())
ballots = (read_file.readline().rstrip()) # the rate of the eligibal votes and registered votes
votes_rate = round(float(ballots) / float(elig_votes) *100,2)
reg_rate = round(float(reg_votes) / float(elig_votes) *100, 2) # if more than 80% voted if reg_vote? > 80:
vote_more_80 += 1
rege_rate = round((ballots/reg_votes) * 100, 2)
# if less than 60% voted
  
if votes_rate
year_under_60 += 1
  
report.write(“In ” + str(year) + “, ” + str(reg_rate) +
“% of eligible voters registered, and ” +
str(vots_rate) + “% voted.n”) # reporet the file line = read_file.readline().rstrip() # test condition year += 1
ballots += ballots
votes_rate += reg_rate # average rate of voters
ave = round(reg_rate + year , 2) # rate of more than 80% voters
voters_80_rate = round(float(votes_more_80)/ float(year) *100,2)   
print(‘The total number of years listed: ‘,year)
print(‘Total ballots in all these years:’,format(ballot,’,’))
print(‘Average percentage of eligible voters registered:’,reg_rate,’%’)
print(‘Number of years with less than 60% of registered voterscasting ‘
‘ballots: ‘,format(year_under_60,’.0f’))
print(‘Percentage of years with more than 80% of registered voterscasting’)
print(‘ballots: ‘, format(votes_rate,’.1f’),’%’)
print(‘An output file named’,report_name ,’has beencreated.’)
print() report.close()
main() . . .

 

Looking for a Similar Assignment? Let us take care of your classwork while you enjoy your free time! All papers are written from scratch and are 100% Original. Try us today! Use Code SAVE15 for 15% discount