Elif syntax error

I am working on https://www.codecademy.com/courses/learn-python/projects/area-calculator and keep getting:

elif option == ‘T’:
^
SyntaxError: invalid syntax

here is what I have:

elif option == ‘T’:
base = float(raw_input(‘Enter base’))
height = float(raw_input(‘Enter height’))
area = 0.5 * base * height
print ‘the area of a triangle with a base of %f and a height of %f is %f’ % (base, height, area)

I can’t seem to figure out where I’ve gone wrong!
Thanks for any help

There is not enough for us to go on. Please post the entire if statement.

Everything I have:

print "This tool will calculate the area of circles and triangles "
print “the tool is now running”
option = raw_input("Enter C for Circle or T for Triangle: ")
if option == ‘C’:
radius = float(raw_input("Enter radius: "))
pi = 3.14
area = pi * radius**2
print “Area: %f” % area

elif option == ‘T’:
base = float(raw_input(‘Enter base’))
height = float(raw_input(‘Enter height’))
area = 0.5 * base * height
print ‘the area of a triangle with a base of %f and a height of %f is %f’ % (base, height, area)

It runs fine with just:

print "This tool will calculate the area of circles and triangles "
print “the tool is now running”
option = raw_input("Enter C for Circle or T for Triangle: ")
if option == ‘C’:
radius = float(raw_input("Enter radius: "))
pi = 3.14
area = pi * radius**2
print “Area: %f” % area

We’re unable to judge how the code is block-indented. In Python, indentation is critical, as is consistent use. If you select your code, then click the </> button, it will preserve your formatting.

Thank you. You’re answer was enough to make me see my problem. I had not used consistent indentation.

1 Like