Feb-25-2018, 05:10 PM
Below is my Homework assignment. I cannot for the life of me figure out why my while loop
doesn't recognize my condition != 'no'. The loop will not exit when 'no' is entered. ANY insight would be great!
# This program will ask a user to input the length of
# three sides to a triangle.When the user inputs the
# side lengths the program will determine whether
# the triangle is Isosceles, Equilateral, Not equilateral or isosceles.
# The program will then give the total number of triangles processed.
doesn't recognize my condition != 'no'. The loop will not exit when 'no' is entered. ANY insight would be great!
# This program will ask a user to input the length of
# three sides to a triangle.When the user inputs the
# side lengths the program will determine whether
# the triangle is Isosceles, Equilateral, Not equilateral or isosceles.
# The program will then give the total number of triangles processed.
def main(): # Initialize counter answer = 0 # Get the user to answer yes or no. userAnswer = str(input("Would you like to enter three sides to a" + \ "triangle? Please answer yes or no:")) # Gather side data side1 = int(input("Side 1 Size?")) side2 = int(input("Side 2 Size?")) side3 = int(input("Side 3 Size?")) # Calculate side data while userAnswer != 'no': answer += 1 if side1 == side2 == side3: print("Equilateral triangle") break elif side1 != side2 != side3: print("Not equilateral or isosceles") break else: print("Isosceles triangle") break print("Processing is complete. You have evaluated", answer, "sets of sides.") main() print("Processing is complete. You have evaluated", answer, "sets of sides.") main()