Given a list of lists, the task is to find whether a sublist satisfies the triangle inequality.
The triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side. In other words, a triangle is valid if sum of its two sides is greater than the third side. If three sides are a, b and c, then three conditions should be met.
a + b > c a + c > b b + c > a
Method #1 : Using List comprehension
[(4, 5, 6)]
Method #2 : Using Iteration
[4, 5, 6]
- Python | Program to count number of lists in a list of lists
- Python | Checking if starting digits are similar in list
- Python | Merge List with common elements in a List of Lists
- Python | Sorting list of lists with similar list elements
- Python | Convert List of lists to list of Strings
- Python | Ways to sum list of lists and return sum list
- Python | Maximum sum of elements of list in a list of lists
- Python - Convert List of Dictionaries to List of Lists
- Python | Check if a list exists in given list of lists
- Python - Convert Key-Value list Dictionary to List of Lists
- Python | Convert list into list of lists
- Python - Sum of different length Lists of list
- Python | Split list into lists by particular value
- Python - Convert Lists of List to Dictionary
- Python | Split nested list into two lists
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.