[Tutor] Need some help

Aaron Brown brownam at gmail.com
Sat May 7 05:35:15 CEST 2011


Here is the code I have, and the error.I don't understand the TUPLE problem.
Can someone explain.

#Main Program
def main():

    notGreenCost = (12,float)
    goneGreenCost = (12, float)
    savings = (12, float)
    months = "January ","February","March ","April ","May ","June ","July
","August ","September ","October ","November ","December "
    for index in range(12):
        print "Enter NOT GREEN energy costs for ", months[index]
        notGreenCost[index]=raw_input("Enter now-> ")
        for index in range(12):
            print "Enter GONE GREEN energy costs for ", months[index]
            goneGreenCost[index]=input("Enter now-> ")
            print "--------------------------------------- "
            print "SAVINGS NOT GREEN GONE GREEN MONTH"
            print "--------------------------------------- "
            for index in range(12):
                savings[index] = notGreenCost(index) - goneGreenCost[index]
                print "$ ", savings[index]
                print "$ ", notGreenCost[index]
                print "$ ", goneGreenCost[index]
                print months[index]
main()


Enter NOT GREEN energy costs for  January
Enter now-> 0
Traceback (most recent call last):
  File "C:\Users\USER\Desktop\P08.py", line 24, in <module>
    main()
  File "C:\Users\USER\Desktop\P08.py", line 11, in main
    notGreenCost[index]=raw_input("Enter now-> ")
TypeError: 'tuple' object does not support item assignment
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110506/daa4acce/attachment.html>


More information about the Tutor mailing list