Answer:
Step-by-step explanation:
The following Python program reads the file called text.txt and loops through each line, removing whitespace and seperating the month and rainfall. Then it prints each Month with its corresponding rainfall amount. Finally it calculates the average rainfall and outputs that.
file = open('text.txt', 'r')
total_rainfall = 0
for line in file:
line = line.replace('\\', '')
info = line.split(' ')
info = [i for i in info if i != '']
print(info[0] + " will have a total of " + info[1] + " inches of rainfall.")
total_rainfall += int(info[1])
average = total_rainfall / 3
print("Average Rainfall will be " + str(average) + " inches")