

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to find the Decreasing point in a List
When it is required to find the decreasing point in a list, a simple iteration and the ‘break’ statement are used.
Example
Below is a demonstration of the same −
my_list = [21, 62, 53, 94, 55, 66, 18, 1, 0] print("The list is :") print(my_list) my_result = -1 for index in range(0, len(my_list) - 1): if my_list[index + 1] < my_list[index]: my_result = index break print("The result is :") print(my_result)
Output
The list is : [21, 62, 53, 94, 55, 66, 18, 1, 0] The result is : 1
Explanation
A list of integers is defined and is displayed on the console.
An integer variable is assigned a value.
The list is iterated over, and the elements in consecutive indices are checked.
If the second index is less than first, the index is assigned to the integer variable.
The control breaks out of the loop.
This is the output that is displayed on the console.
- Related Questions & Answers
- Program to find the highest altitude of a point in Python
- Program to find maximum element after decreasing and rearranging in Python
- Python program to find the String in a List
- Program to check whether list is strictly increasing or strictly decreasing in Python
- Python program to find the largest number in a list
- Python program to find the smallest number in a list
- Program to find the mid-point of a line in C++
- Program to find length of longest strictly increasing then decreasing sublist in Python
- Program to find the Break Even Point in C++
- C++ Program to find out the moves to read a point from another point in a 2D plane
- Python program to find the second largest number in a list
- Python program to find largest number in a list
- Python Program to Find the Length of a List Using Recursion
- Program to find folded list from a given linked list in Python
- C++ Program to find length of maximum non-decreasing subsegment
Advertisements