Im working on my final project for school where i have to uses arrays to store the first year of energy costs, the second array will store the second year after going green, and the third array will store the difference. I have pretty much all the code written out except for the last part of the print results which just displays the information on screen. How ever I keep getting a syntax error for the variable no_cost just as im about to ask the user for input. Is anyone able to help me wrap this project up?
#Date: December 12th 2011
#Purpose: To create a program that allows users to enter energy bills for a year prior to and after going green.
#Then calculate the savings and display the two years of data + savings to the user.
#global constants
NO_OF_MONTHS= 12
MONTHS_OF_YEAR= ["January","February","March","April","May","June","July","August","September","October","November","December"]
def main ():
#real not_green_cost, gone_green_cost, savings
#create 3 arrays to store data
not_green_cost= [0] * 12
gone_green_cost=[0] * 12
savings= [0] * 12
end_program= "yes"
while (end_program.lower() == "yes"):
print ("****This program calculates the energy savings for AK’s College Turned Green****")
#get the not green energy cost's from the user
not_green_cost=get_non_green_cost
#get the green energy cost's from the user
gone_green_cost=get_green_cost
#############################################################################################
#have user enter bills from january-december for prior to going green
def get_not_green_cost ():
#real not_cost[NO_OF_MONTHS]
#int index
not_cost= [0] * NO_OF_MONTHS
MIN_COST=400
MAX_COST=1000
print ("Enter NOT green costs for %s" %MONTHS_OF_YEAR)
for index in range (NO_OF_MONTHS): #0 to NO_OF_MONTHS
not_cost[index]=float (input ("Enter now -->"))
while (not_cost[index] < MIN_COST or not_cost[index] > MAX_COST):
print ("Error in input")
print ("You must enter a value between %.2f and %.2f" %(MIN_COST,MAX_COST)
not_cost [index]=float(input ("Enter now -->"))
return not_cost
#################################################################################################
#have user enter bills from january-december for after going green
def get_green_cost ():
#real green_cost[NO_OF_MONTHS]
#int index
green_cost= [0] * NO_OF_MONTHS
MIN_COST=400
MAX_COST=1000
print ("Enter GONE green costs for %s" %MONTHS_OF_YEAR)
for index in range (NO_OF_MONTHS): #0 to NO_OF_MONTHS
green_cost[index]=float (input ("Enter now -->"))
while (green_cost[index] < MIN_COST or green_cost[index] > MAX_COST):
print ("Error in input")
print ("You must enter a value between %.2f and %.2f" %(MIN_COST,MAX_COST)
green_cost[index]=float(input ("Enter now -->"))
return green_cost
####################################################################################################
#calculate the savings and return it
def calculate_energy_savings (not_cost, green_cost):
#int index
#real savings[NO_OF_MONTHS]
savings= [0] * NO_OF_MONTHS
for index in range (NO_OF_MONTHS):
savings[index]=not_cost[index]-green_cost[index]
return savings
#######################################################################################################
#this function prints the results for the 2 years of data as well as displaying the savings
def print_results
print ("=================SAVINGS==============")
return
######################################################################################################
main ()