def triangle(side1, side2, side3):
if side1 >= side2 + side3 or side2 >= side3 +side1 or side3 >= side1 + side2:
return 'Not a triangle'
elif side1 == side2 == side3:
return 'Equilateral'
elif side1 != side2 != side3:
return 'Scalene'
return 'Isosceles'
The code works fine, but I’m wondering if there’s a more efficient way to write line 2 of the code which goes
‘if any one side of the triangle is greater than or equal to the sum of the other 2 sides’:
New contributor
Philip Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.