Check if List is Strictly Increasing - Python Last Updated : 11 Feb, 2025 Comments Improve Suggest changes Like Article Like Report We are given a list of numbers and our task is to check whether the list is strictly increasing meaning each element must be greater than the previous one. For example: a = [1, 3, 5, 7] this is strictly increasing and b = [1, 3, 3, 7], this is not strictly increasing as 3 appears twice.Using all() with zip()all() function checks if all conditions in an iterable are True and zip() pairs adjacent elements for comparison. Python a = [1, 3, 5, 7] res = all(x < y for x, y in zip(a, a[1:])) print(res) OutputTrue Explanation:zip(a, a[1:]) pairs consecutive elements: (1,3), (3,5), (5,7).generator x < y ensures that each number is strictly less than the next.all(...) returns True only if all comparisons hold.Using itertools.pairwise()pairwise() function from itertools generates consecutive element pairs, making comparisons clean and efficient. Python from itertools import pairwise a = [1, 3, 5, 7] res = all(x < y for x, y in pairwise(a)) print(res) OutputTrue Explanation:pairwise(a) generates adjacent pairs: (1,3), (3,5), (5,7).all(x < y for x, y in pairwise(a)) checks if each element is less than the next.Using a LoopA for loop can be used to compare adjacent elements and check if they are strictly increasing. Python a = [1, 3, 5, 7] res = True for i in range(len(a) - 1): if a[i] >= a[i + 1]: res = False break print(res) OutputTrue Explanation:We iterate through the list using range(len(a) - 1), checking adjacent elements.If a[i] >= a[i+1], the sequence is not strictly increasing, so we set res = False and break the loop.Using sorted()We can check if the list is strictly increasing by comparing it with its sorted version and we sort the list using sorted(). Python a = [1, 3, 5, 7] res = a == sorted(a) and len(set(a)) == len(a) print(res) OutputTrue Explanation:sorted(a) returns a sorted version of a. If a is already sorted, the condition holds.len(set(a)) == len(a) ensures no duplicate elements, making it strictly increasing. Comment More infoAdvertise with us Next Article Check if List is Strictly Increasing - Python manjeet_04 Follow Improve Article Tags : Python Python Programs Python list-programs Practice Tags : python Similar Reads Python - Check if List is K increasing Given a List, check if the next element is always x + K than current(x). Input : test_list = [3, 7, 11, 15, 19, 23], K = 4 Output : True Explanation : Subsequent element difference is 4. Input : test_list = [3, 7, 11, 12, 19, 23], K = 4 Output : False Explanation : 12 - 11 = 1, which is not 4, hence 4 min read Python - Test for strictly decreasing list The test for a monotonic sequence is a utility that has manifold applications in mathematics and hence every sphere related to mathematics. As mathematics and Computer Science generally go parallel, mathematical operations such as checking for strictly decreasing sequences can be useful to gather kn 5 min read Reverse sequence of strictly increasing integers in a list-Python The task of reversing the sequence of strictly increasing integers in a list in Python involves identifying consecutive increasing subsequences and reversing each subsequence individually. For example, given a list a = [0, 1, 9, 8, 7, 5, 3, 14], the goal is to reverse the strictly increasing subsequ 3 min read Check for Sublist in List-Python The task of checking for a sublist in a list in Python involves determining whether a given sequence of elements (sublist) appears consecutively within a larger list. This is a common problem in programming, particularly in data processing and pattern matching. For example, if we have a list [5, 6, 4 min read Python | Check for Descending Sorted List The sorted operation of list is essential operation in many application. But it takes best of O(nlogn) time complexity, hence one hopes to avoid this. So, to check if this is required or not, knowing if list is by default reverse sorted or not, one can check if list is sorted or not. Lets discuss va 3 min read Python | Find groups of strictly increasing numbers in a list Given a list of integers, write a Python program to find groups of strictly increasing numbers. Examples: Input : [1, 2, 3, 5, 6] Output : [[1, 2, 3], [5, 6]] Input : [8, 9, 10, 7, 8, 1, 2, 3] Output : [[8, 9, 10], [7, 8], [1, 2, 3]] Approach #1 : Pythonic naive This is a naive approach which uses a 5 min read Python | Checking triangular inequality on list of lists 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 3 min read Python - Check if list contains consecutive Checking if a list contains consecutive numbers in Python is useful in problems involving sequences, patterns, or data validation. In this article, we explore different methods to check for consecutive numbers in a list.Using sorted() and RangeThis method works by sorting the list and comparing it t 2 min read Python - Check if previous element is smaller in List Sometimes, while working with Python lists, we can have a problem in which we need to check for each element if its preceding element is smaller. This type of problem can have its use in data preprocessing domains. Let's discuss certain problems in which this task can be performed. Input : test_list 5 min read Python - Group each increasing and decreasing run in list Given a list, the task is to write a Python program to group each increasing and decreasing run. This is known as a monotonous grouping. A list is monotonic if it is either monotone increasing or monotone decreasing. A list A is monotone decreasing if for all i <= j, A[i] >= A[j]. Example: Inp 9 min read Like