-2
def rectangle(b,c):
    area_rectangle = b * c
    print (area_rectangle)


def triangle(base,height):
    area_triangle = 1/2 * (base * height)
    print (area_triangle)


a = str(input("Area of what: Triangle or Rectangle? =>"))


if a == "rectangle" or "Rectangle" or "Rec" or "rec":
    rectangle((int(input("Please enter base of rectangle:"))),(int(input("Please enter height of rectangle:"))))
elif a == "Triangle" or "triangle":
    triangle((int(input("Please enter base of triangle:"))),(int(input("Please enter height of rectangle:"))))
else:
    print ("invalid Request")
ForceBru
  • 43,482
  • 10
  • 63
  • 98
  • What do you think `a == "rectangle" or "Rectangle" or "Rec" or "rec"` is equal to for different values of `a`? Also, is `"rectangle" or "Rectangle" or "Rec" or "rec"` a constant? – ForceBru Jul 13 '18 at 16:20
  • Possible duplicate of [Why does \`a == b or c or d\` always evaluate to True?](https://stackoverflow.com/questions/20002503/why-does-a-b-or-c-or-d-always-evaluate-to-true) –  Jul 13 '18 at 16:55

1 Answers1

0

Use this:

if a in ["rectangle" ,"Rectangle" ,"Rec" ,"rec"]:

Same for the triangle.

This happens because in python

if a == 'x' or 'b' or 'c' or 'd' 

is not the same as

if (a =='x') or (a =='b') or  (a == 'c') or ( a == 'd')
Andre Motta
  • 759
  • 3
  • 16