This is the question:
A triangle can be classified based on the lengths of its sides as equilateral, isosceles or scalene. All 3 sides of an equilateral triangle have the same length. An isosceles triangle has two sides that are the same length, and a third side that is a different length. If all of the sides have different lengths then the triangle is scalene. Write a program that reads the lengths of 3 sides of a triangle from the user. Display a message indicating the type of the triangle
And here is my code, which doesn't work:
#this code doesn't work for some reason:
s1, s2, s3 = float(input('Enter three sides (separated by comma): ').split(','))
if s1 == s2 and s2 == s3:
print('Equilateral')
elif (s1 == s2 and s2 != s3) or (s1 == s3 and s2 != s3) or (s2 == s3 and s1 != s2):
print('Isosceles')
else:
print('Scalene')
What am I missing? Thanks in advance.
source https://stackoverflow.com/questions/69726806/how-can-i-separate-these-inputs-and-still-make-them-a-float
Comments
Post a Comment