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 | Checking if starting digits are similar in list
- Python | Program to count number of lists in a list of lists
- Python | Sorting list of lists with similar list elements
- Python | Merge List with common elements in a List of Lists
- Python | Ways to sum list of lists and return sum list
- Python | Maximum sum of elements of list in a list of lists
- Python | Check if a list exists in given list of lists
- Python | Convert list into list of lists
- Python | Split list into lists by particular value
- Python | Custom Multiplication in list of lists
- Python | Merge two lists into list of tuples
- Python | Convert a list into tuple of lists
- Python | Get positive elements from given list of lists
- Python | Remove given element from list of lists
- Python | Column deletion from list of 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 email@example.com. 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.