try: with open("C:\Dave\data.txt") as f : for line in f : name, values = line.split(' = ') values = literal_eval(values) print(f" District: {name}") print(f"Hal received {values[3]} votes AVG: - {values[3] / sum(values):.2%}).") except ZeroDivisionError as error: print(f'Can\'t divide this: {error}')
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags