Hey what's up? We are a free website solely relying on advertisement revenue! Please support us by disabling your adBlock for this site and good things will happen!
in Python | 2018-09-18
Difficulty : Intermediate
def average_file(filename): mtr=open(filename,"r") mylist=mtr.readlines() summ=0 try: for it in mylist: summ+=int(it) fin=summ/len(mylist) except ValueError: mtr.close() return "Error reading file!" mtr.close() return fin