#the main function def main(): endprogram = 'no' while endprogram == 'no': totalbottles = getbottles() totalpayout = calcpayout(totalbottles) printinfo (totalbottles, totalpayout) endprogram = raw_input ('do you want to end the program? (enter yes or no): ') #this function will get the number of bottles returned def getbottles(): totalbottles = 0 todaybottles = 0 counter = 1 while counter <= 7: todaybottles = input ('enter number of bottles for today: ') totalbottles = totalbottles + todaybottles counter = counter + 1 return totalbottles #this function will display the information def printinfo(totalbottles, totalpayout): print 'the total number of bottles collected was', totalbottles print 'the total paid out was $', totalpayout #calls main main()
Traceback (most recent call last): File "C:/Documents and Settings/Owner/Desktop/lab5.4.py", line 32, in <module> main() File "C:/Documents and Settings/Owner/Desktop/lab5.4.py", line 10, in main totalbottles = getbottles() UnboundLocalError: local variable 'getbottles' referenced before assignment
This post has been edited by JackOfAllTrades: 16 May 2010 - 05:37 AM
Reason for edit:: Added code tags.