Assume that a file containing a series of integers is named numbers.txt. Write a program that calculates average of all thernumbers stored in the file and prints the average on the screen.
The code that does not work. How can I add try except ZeroDivision Error into the code?
file=open("numbers.txt", "r");count=0sum=0content=file.readlines()for nums in content: num=nums.split("") for i in num: sum=sum+int(i) count=count+1print("Average:"+str(sum/count))
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here