Home  >  Article  >  Backend Development  >  How to use the max function in a two-dimensional list

How to use the max function in a two-dimensional list

php中世界最好的语言
php中世界最好的语言Original
2018-04-09 15:18:243380browse

This time I will show you how to use the max function in a two-dimensional list. What are the precautions when using the max function in a two-dimensional list. The following is a practical case. Let’s take a look.

I discovered this recently while writing an algorithm related to two-dimensional lists

When max is used to find the maximum value in a two-dimensional list, the output result is the list with the largest first element of the sublist

The test is as follows

c=[[1,2,-1],[0,5,6]] 
a=[[0,3,-1],[1,4,6]] 
print(max(c),max(a))

The result is like this

[1, 2, -1] [1, 4, 6]

I believe it After reading the case in this article, you have mastered the method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Recommended reading:

How to obtain the local peak value of a two-dimensional array in python

How to use OpenCV with the Python interface

The above is the detailed content of How to use the max function in a two-dimensional list. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn