Triangle Validity Check

Write a program to check if a triangle can be formed given the lengths of its sides (a, b, c) entered by the user.

Example 1:

Input: (3, 4, 5)

Output: True

Example 2:

Input: (1, 1, 3)

Output: False

A triangle can be formed if the sum of the lengths of any two sides is greater than the length of the third side.

def is_triangle(sides):
    a, b, c = sides
    if (a + b > c) and (a + c > b) and (b + c > a):
        return True
        return False

© Let’s Data Science


Unlock AI & Data Science treasures. Log in!