Check Yourself


#1

Hello!

I keep getting an error message saying that line 25 (else line) has a syntax error. I am not sure how to fix it. Thank you!

sleep(1)
print ("Area: %.2f. \n%s" % (area, hint))
else:
print "Error! INvalid shape selector specified. Exiting."


#2

@jlbenson,
Please provide the FULL code you are using.

Place 3 so-called back-ticks ```
in a line above your code
in a separate line after your code
You are then able to present us with the proper indentation
```
your code
```


#3

Hey there. Pretty sure this isn't PygLatin. Maybe it's the Area Calculator instead? Also, the lines aren't numbered here so we don't know which line is 25. Can you maybe do a screenshot? Also, it may be a syntax error due to indenting?


#4

Sorry here is my full code. And you are right this is for the Area Calculator I'm sorry.
It gives the error "Line 25 else syntax error: invalid syntax

""" With this calculator you will be able to compute the area of either a circle or a triangle."""
from math import pi
from time import sleep
from datetime import datetime
now = datetime.now()
print "The calculator is now starting!"
print "Current time: %s/%s/%s %s:%s" % (now.month, now.day, now.year, now.hour, now.minute)
sleep(1)
hint = "Dont forget to include the correct units! \nExiting..."
option = raw_input("Enter C for Circle or T for Triangle: ")
option = option.upper()
if option == 'C':
	radius = float(raw_input("Enter radius of the circle: "))
	area = pi * radius ** 2
	print "The pie is baking..."
	sleep(1)
	print ("Area: %.2f. \n%s" % (area, hint)) 
elif option == 'T':
  base = float(raw_input("Enter base of the triangle: "))
  height = float(raw_input("Enter the height of the triangle: "))
  area = (0.5)*base*height
  print "Uni Bi Tri..."
  sleep(1)
  print ("Area: %.2f. \n%s" % (area, hint))
  else:
    print "Error! Invalid shape selector specified. Exiting."

#5

Never mind I figured it out!


#6

@jlbenson,
And what did you do...??

""" With this calculator you will be able to compute the area of either a circle or a triangle."""
from math import pi
from time import sleep

#from datetime import datetime
now = datetime.now()
print "The calculator is now starting!"
print "Current time: %s/%s/%s %s:%s" % (now.month, now.day, now.year, now.hour, now.minute)
#sleep(1)
hint = "Dont forget to include the correct units! \nExiting..."
#option = raw_input("Enter C for Circle or T for Triangle: ")
#option="T"
option="C"
option = option.upper()
if option == 'C':
   radius=1.2
   #radius = float(raw_input("Enter radius of the circle: "))
   area = math.pi * radius ** 2
   print "The pie is baking..."
   #sleep(1)
   #deactivated as it could cause 
   # Internal error: ReferenceError: _select is not defined
   print ("Area: %.2f. \n%s" % (area, hint)) 
elif option == 'T':
  base=float(1.2)
  #base = float(raw_input("Enter base of the triangle: "))
  height=float(1.6)
  #height = float(raw_input("Enter the height of the triangle: "))
  area = (0.5)*base*height
  print "Uni Bi Tri..."
  #sleep(1)
  print ("Area: %.2f. \n%s" % (area, hint))
else:
  print "Error! Invalid shape selector specified. Exiting."

#7

print between last sleep and else it's not necesary. I think


#8