Here's the syntax of the problem I'm facing:
Heating and cooling degree-days are measured by utility companies to estimate energy requirements. If the average temperature for a day is below 60, then the number of degrees below 60 is added to the heating degree-days. If the temperature is above 80, the amount over 80 is added to the cooling degree-days. Write a program that accepts a sequence of average daily temps and computes the running total of cooling and heating degree-days. The program should print these two totals after all the data has been processed.
When I run my program, it will let me input temps, but when I press enter to signify I'm done entering in data I get the return "Unknown error". Thanks for the assistance.
def main():
print("Please enter daily average temperature below. Leave empty when finish.")
hdd,cdd,hot,cool = 0,0,0,0
date = 1
try:
temp = input("Day #{} :".format(date))
while temp != "":
temp = int(temp)
if temp > 80:
cdd = (temp-80)+cdd
if temp < 60:
hdd = (60-temp)+hdd
date = date+1
temp = input("Day #{} :".format(date))
print("In {} days, there\'r total of {} HDD and {} CDD.".format(date-1,hdd,cdd))
except ValueError:
print('Please correct your data.')
except:
print('Unknown error.')
main()