import urllib,json d=json.loads(urllib.urlopen("https://intf.nyt.com/newsgraphics/2016/11-08-election-forecast/president.json").read())["president"] print("""As of {timestamp}: Clinton: Votes: {electoral_votes_counted[clintonh]}/270 Counted: {vote_share_counted[clintonh]:.3%} Win prob: {win_prob[clintonh]:.3%} Trump: Votes: {electoral_votes_counted[trumpd]}/270 Counted: {vote_share_counted[trumpd]:.3%} Win prob: {win_prob[trumpd]:.3%}""".format(**d["timeseries"][-1])) print("\n".join( "{state}: {current[winner][name_display]}".format(**s) if s["current"]["winner"] else "{state}: Undecided, {current[percent_counted]:.1%} counted - Clinton: {current[win_prob][clintonh]:.1%}, Trump: {current[win_prob][trumpd]:.1%}".format(**s) for s in d["races"] ))