Code Academy Python Course Project :AreaCalculator

https://www.codecademy.com/courses/learn-python/projects/area-calculator?action=resume_content_item

This is my code:

#This program will prompt use to enter a shape. They will have the choice of the following shapes: Circle, Triangle.  Program will then calculate and print are of shape.
print 'Area Calculator is Starting Up....'
option = raw_input("Enter C for Circle or T for Trianlge? ")

if option == 'C':
  radius = float(raw_input("Enter a radius: "))
  area = 3.14 * radius ** 2
  print 'The area of a circle with a radius of %s is %s' % (radius,area)
  
elif option == 'T':
	base = float(raw_input("Enter a Base: ?"))
	height = float(raw_input("Enter a Height: ?"))
	area = .5 * base * height
print "The area of a Triangle with a base of %s and a Height of %s is %s" % (base, height, area)

else:
  print "Be Happy"

Keep getting an error Syntax Error for else statement:

Am I missing something? Please help

The print line in the elif clause is outside of the block. This will leave the else out on its own and unexpected.

Be sure your indentation is consistent for readability and debugging. Using four space characters is the norm.

Thank you so much mtf. I am new to Python but determined.

1 Like