
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python – Maximum in Row Range
When it is required to find the maximum value in a row range, a simple iteration and the ‘max’ method is used.
Below is a demonstration of the same −
Example
my_list = [[11, 35, 6], [9, 11, 3], [35, 4, 2],[8, 15, 35], [5, 9, 18], [5, 14, 2]] print("The list is :") print(my_list) i, j = 2, 4 print("The values for integers are ") print(i, j) my_result = 0 for index in range(i, j): my_result = max(max(my_list[index]), my_result) print("The result is :") print(my_result)
Output
The list is : [[11, 35, 6], [9, 11, 3], [35, 4, 2], [8, 15, 35], [5, 9, 18], [5, 14, 2]] The values for integers are 2 4 The result is : 35
Explanation
A list of list is defined and is displayed on the console.
The values for two integers are defined and displayed on the console.
A variable is initialized to 0.
The integers are taken as range values and iterated over.
The maximum of index element is taken, and assigned to the variable.
This is the output that is displayed on the console.
- Related Articles
- Python - Sort Matrix by Maximum Row element
- Python – Display the key of list value with maximum range
- Program to find maximum sum by flipping each row elements in Python
- Find the maximum element of each row in a matrix using Python
- Maximum Subarray Sum in a given Range in C++
- Maximum prefix-sum for a given range in C++
- Maximum Bitwise AND pair from given range in C++
- MySQL limit in a range fail to display first 3 row?
- Find row with maximum sum in a Matrix in C++
- Python map function to find the row with the maximum number of 1’s
- Smallest Range I in Python
- How to divide data frame row values by maximum value in each row excluding 0 in R?
- Python program using map function to find row with maximum number of 1's
- Python Pandas – Find the maximum value of a column and return its corresponding row values
- Find maximum element of each row in a matrix in C++

Advertisements