Im writing this program that draws a bar graph showing an investment growth. and this error keeps coming up and i cant figure it out. this is the syntax that python keeps telling me.
Traceback (most recent call last): File "C:\Python26\lala.py", line 68, in <module> main() File "C:\Python26\lala.py", line 47, in main height = principal * 0.02 TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
and this is my code
#import your graphics from graphics import * # graphs future value by displaying it in a graphic window def main(): #===Draws a graph window win = GraphWin("Future Value",400,300) win.setCoords(0.0, 0.0, 3.0, 4.0) #===displays what the program does and gives user instructions Text(Point(1.5,3.5), "This Plots the growth of a 10-year investment.").draw(win) Text(Point(1,3), " Enter the initial Principal:").draw(win) Text(Point(1,1), " Enter annualized interest rate:").draw(win) #===This is the user enter principal data def principal_data(): input = Entry(Point(2,3), 5) input.setText("0.0") input.draw(win) principal_data() #===This is the user enter apr date def apr_data(): input = Entry(Point(2,1), 5) input.setText("0.0") input.draw(win) apr_data() #===draws the calculate button in the graph wun button = Text(Point(1.5,2.0), "Calculate") button.setFill('red') button.draw(win) Rectangle(Point(1,1.5), Point(2,2.5)).draw(win) #===wait for a user mouse click win.getMouse() principal = principal_data() apr = apr_data() #===create a graphics window with labels on left edge win = GraphWin("Investment Growth Chart", 320, 240) win.setBackground('white') #===draws the labels on the left edge Text(Point(20, 230), '0.0k').draw(win) Text(Point(20, 180), '2.5k').draw(win) Text(Point(20, 130), '5.0k').draw(win) Text(Point(20, 80), '7.5k').draw(win) Text(Point(20, 30), '10.0k').draw(win) #===draw bar for initial principal height = principal * 0.02 bar = Rectangle(Point(40, 230), Point(65, 230-height)) bar.setFill('green') bar.setWidth(2) bar.draw(win) #===draw bars for successive years for year in range(1,11): #=======calculate value for the next year principal = principal * (1 + apr) #=======draw bar for this value xll = year * 25+40 height = principal * 0.02 bar = Rectangle(Point(xll, 230), Point(xll+25, 230-height)) bar.setFill('green') bar.setWidth(2) bar.draw(win) raw_input("press <enter> to quit") win.close() main()