# It always thinks I entered C

#1

The message I’m getting:

No matter what, it always responds as though I entered C.

My code:

``````"""
This program should be able to:
1. Prompt the user for a shape (a circle or a triangle)
2. Compute the area of that shape
3. Print the area of that shape for the user.
"""
def AreaCalculator():
print("Firing up the clackalater...")
option = raw_input("Enter C for Circle or T for Triangle: ")
if option == 'C' or 'c':
area = 3.14159 * radius ** 2
print("The area of your cicle is " + str(area) + ".")
elif option == 'T' or 't':
base = float(raw_input("The base of my triangle is: "))
height = float(raw_input("The height of my triangle is: "))
area = (base * height) / 2
print("The area of your triangle is " + str(area) + ".")
else:
print("Invalid response.")
print("""Pressing CE...
pressing Power...""")

AreaCalculator()
``````

I know it didn’t say to format it as a function, but I thought maybe that would help me have more control over the flow of the program. It does the exact same thing whether I put the code inside a function or not.
I tried to debug it at repl.it, but programs with `raw_input()` never work outside of Codecademy and I don’t know why.
Edit: the `else` block doesn’t appear to be working either:

#2

This will always be True since `'c'` is not an empty string.

``if option == 'C' or option == 'c':``

#3

Thank you. Changing it to `if option == 'C' or option == 'c':` and `'if option == 'T' or option == 't':` did the trick. I never remember how to format those. I can never remember if it’s `if x == 1 or 2` or if it’s `if x == 1 or if x == 2` or if it’s `if x == 1 or x == 2`.

I don’t understand your remark about ‘c’ not being an empty string.

#4

Any non-empty string is truthy in a conditional. Only the empty string, `''` and `""` are falsy.

``````if option == 'C' or 'c':
``````

Given that option is not `'C'`, we have,

``````if False or True:
``````

Aside

Two other approaches to writing the conditional are,

``````if option.lower() == 'c':
``````

or,

``````if option in 'Cc':
``````

but it does not mean what you have is in any way incorrect or inferior to the above. We have choices, after all.

#5

Ohh, okay that stuff, from Conditionals and Control Flow. Thank you.

#6

2 posts were split to a new topic: I cann’t get mine to work even at this point

#7

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