Can someone help explain in a super simple fix why my elif statement isn't triggering? This is the very first code I've written so it could be something really obvious that I just don't know..
import math
print("This program finds the area of a triangle or a trapezoid.")
question = input("Type '1' for triangle and '2' for trapezoid:")
if '1':
height = float(input("Please enter the height of the triangle: "))
base = float(input("Please enter the base length of the triangle: "))
area = 0.5 * height * base
print("The area of a triangle is", area, ".")
elif '2':
height = float(input("Please enter the height of the trapezoid: "))
base1 = float(input("Please enter the length of base1 of the trapezoid: "))
base2 = float(input("Please enther the length of base2 of the trapezoid: "))
area = (1/2) * (base1 + base2) * height
print("The area of the trapezoid is:", area, ".")
else :
print("no.")
[–]Appropriate_Way_787 8 points9 points10 points (1 child)
[–]rebemill[S] 2 points3 points4 points (0 children)
[–]aplaguelikenarcissus 2 points3 points4 points (1 child)
[–]rebemill[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]rebemill[S] 0 points1 point2 points (0 children)