← Back to challenges

What Type of Triangle?

PythonHardconditionsmatharraysgeometry

Instructions

Create a function which returns the type of triangle, given the side lengths. Return the following values if they match the criteria.

  • No sides equal: "scalene"
  • Two sides equal: "isosceles"
  • All sides equal: "equilateral"
  • Less or more than 3 sides given: "not a triangle"

Examples

get_triangle_type([2, 6, 5]) ➞ "scalene"

get_triangle_type([4, 4, 7]) ➞ "isosceles"

get_triangle_type([8, 8, 8]) ➞ "equilateral"

get_triangle_type([3, 5, 5, 2]) ➞ "not a triangle"

Notes

  • You will be given a list of positive integers.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Next Perfect Square