 # Stuck in Area Calculator_Pls Help

Hi all!

I stuck in Area Calculator section (https://www.codecademy.com/courses/learn-python/projects/area-calculator) for more than 2 hours. The input always shows “Enter Radius” even I put ‘T’ or ‘Triangle’. I have no idea where I did the code wrong. Please help me. T^T

Following is my code:

“”"
Hi
Love to meet you
“”"
print “Starting the calculator…”

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

if option == “C” or “Circle”:

elif option == “T” or “Triangle”:
base = float(raw_input("Enter base: "))
height = float(raw_input("Enter height: "))
area = 0.5 * base * height
print “Base:%s, Height:%s, and Area:%s” % (base,height,area)

else:
“Error”

Best,

Nan

1 Like

If you were to put parentheses in that to clarify order of operations, how would you do it, and what values would `or` therefore receive as its inputs?

``````(option == "T") or "Triangle"
option == ("T" or "Triangle)"
``````

It seems like either way you’re giving `or` a string, doesn’t it? What is `or` supposed to do, and do strings make sense as input to that?

1 Like

Hi there!

Thanks for your suggestions! Nice to meet you, my new friend. Yes, I intend to let the users type either the initial (e.g. T) or the full word (e.g. Triangle). I try to work on something different from the current lesson. Now I got my code working! Following is my new code:

“”"
Hi
Love to meet you
“”"
print “Starting the calculator…”

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

if option == “C” or option == “Circle”:

elif option == “T” or option == “Triangle”:
base = float(raw_input("Enter base: "))
height = float(raw_input("Enter height: "))
area = 0.5baseheight
print “Base is %s, Height is %s, and Area is %s” % (base,height,area)

else:
print “Error! Invalid shape.”
print “Exiting…”

Regards,

Nan

1 Like