Commit f62e4035 authored by Børge Haugset's avatar Børge Haugset
Browse files

fikset noen småfeil

parent 660d1427
...@@ -28,7 +28,7 @@ def read_from_file(): ...@@ -28,7 +28,7 @@ def read_from_file():
while(linje): while(linje):
liste = linje.split(',') liste = linje.split(',')
try: try:
dikt = update_state(dikt, liste[0], liste[1], liste[2]) dikt = update_state(dikt, liste[0], int(liste[1]), int(liste[2]))
except: except:
print(f'Linje kunne ikke tolkes: {linje}') print(f'Linje kunne ikke tolkes: {linje}')
linje = f.readline().strip() linje = f.readline().strip()
...@@ -62,10 +62,12 @@ def find_percent(state,votes): ...@@ -62,10 +62,12 @@ def find_percent(state,votes):
for el in votes[state]: for el in votes[state]:
dem += int(el[0]) dem += int(el[0])
rep += int(el[1]) rep += int(el[1])
prosent_dem = dem*100/(dem+rep) return calculate_percentage((dem, rep))
return (round(prosent_dem,2),round(100-prosent_dem,2))
# Her var det en veldig åpen oppgave, så det er ikke så rart at noen
# tolket det som at de skulle lese inn fil og slikt. Vi hadde i
# utangspunktet tenkt at votes inn skulle være den fra 3.4.
def print_nation_results(votes): def print_nation_results(votes):
dem,rep = 0,0 dem,rep = 0,0
ev_norm_dem,ev_norm_rep = 0,0 ev_norm_dem,ev_norm_rep = 0,0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment