Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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] 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.
Advertisements
