My code doesn't work. Indent problem?


Hi everyone! I am trying to do the AreaCalculator project but for some reason I keep getting indent errors. I just don't understand what I'm doing wrong. Any help will be appreciated.

This program allows users to calculate the area of circles and triangles.

from math import pi
from time import sleep
from datetime import datetime
now =

print "calculator starting up!"
print "current time: %s/%s/%s %s:%s" % (now.month,, now.year, now.hour, now.minute)


hint = "Don't forget to include the correct units! \nExitting..."

option = raw_input("Enter C for Circle or T for Triangle:")
option = option.upper()

if option == "C":
    radius = float(raw_input("Input circle radius:"))
    circle_area = pi*radius**2
    print "The pie is baking..."
    print ("Circle Area: %.2f \n%s" % (circle_area, hint))

    elif option == "T":
        base = float(raw_input("Input triangle base:"))
  	height = float(raw_input("Input triangle height:"))
  	triangle_area = (0.5)*base*height
	print "Uni Bi Tri..."
	print ("Triangle Area: %.2f \n%s" % (triangle_area, hint))

  	print "False inputs entered; program exiting"


Your elif needs to align with your if statement. As written, the elif is inside the if statement.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.