Can anyone help me find this syntax error?


#1

This one is bugging me, getting this error message from my code.

SyntaxError: invalid syntax                                                            
$ python AreaCalculator.py                                                             
  File "AreaCalculator.py", line 23                                                    
    elif option == 'T':                                                                
       ^                                                                               
SyntaxError: invalid syntax

Any ideas?

"""
This code will work out the area of a shape decided
by the user and print that area
"""

from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()

print "Caculator is starting up"
print "Current time: %s/%s/%s %s:%s" % (now.month, now.day, now.year, now.hour, now.minute)
sleep(1)
hint = "don't forget to include the correct units! \nExiting..."
option = raw_input("Enter T for triangle or C for circle")
option = option.upper()
if option == 'C':
    radius = float(raw_input("enter the radius of the sphere"))
    area = pi*(radius ** 2)
    print "pie is baking..."
    sleep(1)
    print ("Area: %.2f. \n%s" % (area, hint)
elif option == 'T':
    base = float( raw_input(" enter base or triangle"))
    area = 0.5* base**2
    print "uni bi tri"
    slee(1)
    print ("Area: %2f. \n%s" % (area, hint))
else:
    print"error! invalid shape specified. exiting"

#2

What you're allowed to write at a certain place depends on what has been written so far.


#3

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