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

php中世界最好的语言
Release: 2018-04-09 15:18:24
Original
3435 people have browsed it

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))
Copy after login

The result is like this

[1, 2, -1] [1, 4, 6]
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!