🌐
GeeksforGeeks
geeksforgeeks.org › python › python-max-function
Python - max() function - GeeksforGeeks
July 15, 2025 - Python max() function returns the largest item in an iterable or the largest of two or more arguments.
🌐
W3Schools
w3schools.com › python › ref_func_max.asp
Python max() Function
Python Examples Python Compiler ... Q&A Python Training ... The max() function returns the item with the highest value, or the item with the highest value in an iterable....
Discussions

79-character column limit is a nightmare
Well it is what it is. I used to be hostile to the 79-character limit until I realized that on my widescreen laptop, I could fit two code buffers side-by-side with no wrap or truncation if I did the 79-char limit. Since then I've been converting a lot of code. Here's a couple of tips that have helped me keep the code under 80 characters and not too ugly: Use triple-quoted strings if whitespace doesn't matter (e.g. HTML strings or SQL queries). Define long strings like error messages somewhere else (an include file, as static class members, whatever makes sense). If you've got a long function call or collection that's going to need to be broken up, break after the opening paren/brace/bracket. According to my linter (if not PEP8), you only need to indent 4 spaces if you break after the opening delimter. Otherwise you indent all the way up to the first value. For example: instead of this: some_object.long_method_name("fizz", "buzz", "fozz", "bizz", "quux", 1, "lemon", "spam") this: some_object.long_method_name( "fizz", "buzz", "fozz", "bizz", "quux", 1, "lemon", "spam" ) or even this: some_object.long_method_name( "fizz", "buzz", "fozz", "bizz", "quux", 1, "lemon", "spam" ) I don't know that I've ever gotten to the point of consulting a thesaurus to make my comments shorter; are you dealing with some deeply nested comments? EDIT: can't get the code to line up right on reddit, but you get the idea. More on reddit.com
🌐 r/learnpython
44
18
September 27, 2014
min() vs 'sort() and then list[0]'

As others have mentioned, min will be quicker. min just has to walk through the list once, whereas sort must do more compares, making it more complex.

However, one case you might want to use sort is when you need more than just the minimum. Eg. you want the 5 smallest items, not just the smallest. Here "sorted(mylist)[:5]" will do the job, but another option to keep in mind is the heapq module, as "heapq.nsmallest(5, mylist)" will often perform better than sort, at least for a small number of items.

More on reddit.com
🌐 r/Python
36
29
February 23, 2012
How do I find the relative maximum in a function?
Take the derivative and find where it equals zero. Also, do your calculus homework using calculus! But seriously - give us more context. You really can use numpy/scipy to get a derivative, or you can scan the function with some arbitrary input, or you can ask questions we can't answer without proper setup. WHY are you trying to find a local maxima? What inputs do you have? What context is this in? More on reddit.com
🌐 r/Python
7
1
January 23, 2014
How long should a .py file be?
Generally, I don't care about the line count of a module. I group my classes / functions in a way that seems natural. Some modules are only 50 lines long. Others reach the 1000. After all, what difference does pure line count make once it's beyond "more than a couple of screens full"? More on reddit.com
🌐 r/Python
33
13
July 8, 2012
People also ask

What is the use of the max() and min() functions in Python?
We use Python's max() and min() functions to get the maximum or minimum object out of a set of objects or max/min object out of objects in a given iterable.
🌐
interviewkickstart.com
interviewkickstart.com › home › blogs › learn › max() function in python: syntax, parameters, and examples
max() Function in Python: Syntax, Parameters & Examples
What is the difference between the Python max() and min() functions?
Both compare items or items within an iterable on some basis and return a value. But the max() function in Python returns the max value after those comparisons, and the min() function returns the minimum value.
🌐
interviewkickstart.com
interviewkickstart.com › home › blogs › learn › max() function in python: syntax, parameters, and examples
max() Function in Python: Syntax, Parameters & Examples
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › max.html
max — Python Reference (The Right Way) 0.1 documentation
Returns the largest item in an iterable or the largest of two or more arguments · max (collection[, key])
🌐
Programiz
programiz.com › python-programming › methods › built-in › max
Python max()
key (optional) - key function where the iterables are passed and comparison is performed based on its return value · default (optional) - default value if the given iterable is empty · max() returns the largest element from an iterable. ... If the items in an iterable are strings, the largest ...
🌐
Letpy
letpy.io › handbook › builtins › max
Built-in Python Function max: Documentation, Description, and Examples
key (optional): A key function ... and this argument is not specified, a ValueError is raised. max() identifies and returns the element with the highest value in the specified iterable or among the arguments....
🌐
ThePythonGuru
thepythonguru.com › python-builtin-functions › max › index.html
Python max() function - ThePythonGuru.com
The max() function returns the largest of the input values.Its syntax is as follows:max(iterable[, default=obj, key=func]) -> value PARAMETER …
Find elsewhere
🌐
AskPython
askpython.com › python › built-in-methods › python-max-method
Python max() Function: Find the Largest Value - AskPython
5 days ago - Python’s built-in max() function returns the greatest item from an iterable or the greatest of two or more separate values.
🌐
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .max()
Python:NumPy | Built-in Functions | .max() | Codecademy
July 2, 2025 - Returns the maximum value of an array or maximum values along a specified axis.
🌐
Interview Kickstart
interviewkickstart.com › home › blogs › learn › max() function in python: syntax, parameters, and examples
max() Function in Python: Syntax, Parameters & Examples
April 1, 2026 - The same comparison pattern is ... Python is a built-in function that returns the largest value from either an iterable (like a list or tuple) or from multiple arguments passed directly....
🌐
Hyperskill
hyperskill.org › university › python › max-in-python
Python max() Function — Syntax, key Parameter & Examples
August 10, 2026 - The max() function finds the maximum value among elements of an iterable or a series of arguments. It returns the largest item based on the default ordering or a custom ordering specified by the optional key parameter. When used with iterables like lists or tuples, the function compares the ...
🌐
Leapcell
leapcell.io › blog › understanding-python-min-and-max-functions
Understanding Python’s `min()` and `max()` Functions | Leapcell
July 25, 2025 - In Python, the min() and max() functions are built-in utilities used to find the smallest and largest items, respectively, in an iterable or among two or more arguments.
🌐
ZetCode
zetcode.com › python › max-builtin
Python max Function - Complete Guide
April 11, 2025 - The Person class implements __gt__ to compare by age. When we call max on a list of Person instances, Python uses this method. This pattern is useful when you want objects to have a natural ordering for comparison operations. The max function raises ValueError when used with empty iterables.
🌐
Jobtensor
jobtensor.com › Tutorial › Python › en › Builtin-Functions-max
Python Built-in max(), Definition, Syntax, Parameters, Examples | jobtensor
The max() function returns the item with the highest value, or the item with the highest value in an iterable.
🌐
Vultr Docs
docs.vultr.com › python › built-in › max()
Python max() - Find Maximum Value
September 27, 2024 - The max() function in Python is a built-in utility that identifies the maximum value among the provided arguments or elements within an iterable.
🌐
Unstop
unstop.com › home › blog › python max() function | all use cases with code examples
Python max() Function | All Use Cases With Code Examples
February 12, 2025 - Python max() function helps find the largest value among multiple objects or iterable items. Use the optional parameters key & default to customize its behavior.
🌐
LabEx
labex.io › tutorials › python-how-to-use-max-function-effectively-464740
How to use max function effectively | LabEx
The max() function is a built-in Python function that returns the largest item in an iterable or the largest of two or more arguments.
🌐
Devcuriosity
devcuriosity.com › manual › details › python-max-function
Python - max() function with examples - DevCuriosity
max(iterable_1, ..., key=func, default=obj) returns the largest item from a single iterable or the largest of two or more arguments. Accepts optional key-word key argument that needs to be a function that will be used to evaluate each item's number/value.
🌐
Tutorialspoint
tutorialspoint.com › python › number_max.htm
Python max() Function
The Python max() function is used to retrieve the largest element from the specified iterable. Finding the maximum of two given numbers is one of the usual calculations we perform.
🌐
Python Tutorial
pythontutorial.net › home › python built-in functions › python max() function
Python max(): Return the Maximum Item
September 15, 2022 - The max() function also accepts an iterable and returns the maximum item of the iterable: ... key is an optional keyword-only argument that specifies the key for comparing the items of the iterable. default is an optional keyword-only argument that specifies a value that the max() returns when ...