๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-max-function
Python - max() function - GeeksforGeeks
July 15, 2025 - ... By default, it will return the string with the maximum lexicographic value. In this example, as max() is used to locate the largest item in Python, we are using max() to find maximum out of 3 string variable.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_max.asp
Python max() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview 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

Creating a max function from scratch (python) - Stack Overflow
Your if statement is effectively saying that if item is greater than Max, set item to Max. You need to flip that to say if item is greater than Max, set Max to item. ... Also, I'm not an expert in Python, but i think you need to change the List inside your function to match the parameter name, ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
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
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
๐ŸŒ
Real Python
realpython.com โ€บ ref โ€บ builtin-functions โ€บ max
max() | Pythonโ€™s Built-in Functions โ€“ Real Python
You can use max() with the .items() method and a lambda function as the key argument: Language: Python ยท >>> prices = { ... "banana": 1.20, ... "pineapple": 0.89, ... "apple": 1.57, ... "grape": 2.45, ... } >>> max(prices.items(), key=lambda item: item[1]) ('grape', 2.45) This example demonstrates how max() can help you identify the most expensive products by using the dictionaryโ€™s values for comparison.
๐ŸŒ
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 - It works with common Python data types such as numbers, strings, and collections like lists, tuples, and sets. The same comparison pattern is shared by min(), which follows the same syntax but returns the smallest value instead. The max() function in 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 - It efficiently determines and returns the highest value within that sequence, which is valuable for data analysis or identifying the largest element in a dataset. The function can compare multiple values without needing complex if-else statements or loops, enhancing code readability and simplicity. Additionally, max() can handle different object types and is not limited to simple numerical values.
๐ŸŒ
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 item (ordered alphabetically) is returned. languages = ["Python", "C Programming", "Java", "JavaScript"]
๐ŸŒ
Learn By Example
learnbyexample.org โ€บ python-max-function
Python max() Function - Learn By Example
April 20, 2020 - L = [300, 500, 100, 400, 200] x = max(L) print(x) # Prints 500
Find elsewhere
๐ŸŒ
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 โ€ฆ
๐ŸŒ
Devcuriosity
devcuriosity.com โ€บ manual โ€บ details โ€บ python-max-function
Python - max() function with examples - DevCuriosity
Here, we provided not one, but two iterables to max(). And without a specific function, max() checked that 100 is bigger than 4, so it returned [100, 4]. my_list_1 = [5, 100, 999] my_list_2 = [100, 4] my_max = max(my_list_1, my_list_2, key=lambda x: sum(x)) print(my_max) # [5, 100, 999] ... In ...
๐ŸŒ
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 - When working with strings, the max() function can be used to find the "largest" string based on lexicographical (or alphabetical) order. This means the strings are compared character by character, just like how words are arranged in a dictionary. In this basic Python program example, we have illustrated how to use the max() function to compare strings lexicographically (alphabetical order) and find the maximum string.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ number_max.htm
Python max() Function
Here we are retrieving the largest number of the arguments passed to the function. print ("max(80, 100, 1000) : ", max(80, 100, 1000)) print ("max(-20, 100, 400) : ", max(-20, 100, 400)) print ("max(-80, -20, -10) : ", max(-80, -20, -10)) print ...
๐ŸŒ
Pierian Training
pieriantraining.com โ€บ home โ€บ using the max function in python
Using the Max Function in Python - Pierian Training
April 28, 2023 - The `max()` function in Python is a built-in function that returns the maximum value from a given iterable object. The iterable can be a list, tuple, set, or any other sequence. The `max()` function takes one or more arguments and returns the largest element from them. Hereโ€™s an example of using the `max()` function on a list of numbers:
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ python-max-function
Python max Function
December 29, 2018 - # Dictionary Example maxDictionary = {7: 100, 2: 40, 9: 10, 5: 60, 1: 420, 3: 120} print("Largest Key = ", max(maxDictionary.keys())) print("Largest Value = ", max(maxDictionary.values())) maxStringDictionary = {1: 'grape', 2: 'banana', 3: 'cherry'} ...
๐ŸŒ
Digiedutech
digiedutech.com โ€บ techhub โ€บ python โ€บ built-in-functions โ€บ max-function
Python max() Function: Syntax, Examples & Use Cases
April 9, 2026 - Explanation: The max() function checks all numbers in the list and returns the largest value, which is 18. result = max("banana", "apple", "cherry") print(result) #Output: 'cherry' Explanation: Python compares strings in lexicographical (dictionary) order and returns the largest string, which ...
๐ŸŒ
ZetCode
zetcode.com โ€บ python โ€บ max-builtin
Python max Function - Complete Guide
April 11, 2025 - The key function parameter enables finding maximum values based on custom criteria. This example finds the longest word in a list.
๐ŸŒ
PhoenixNAP
phoenixnap.com โ€บ home โ€บ kb โ€บ devops and development โ€บ python max() function: syntax, usage, examples
Python max() Function: Syntax, Usage, Examples | phoenixNAP KB
April 28, 2026 - You can pass a single iterable to max() to evaluate all its elements. This is the most common usage in real-world code. ... If the iterable is empty, Python raises a ValueError. You can prevent this by adding the default parameter: ... The key parameter allows you to apply a transformation before comparison. This is often used with built-in functions like len(). In the following example, max() compares the lengths of the strings instead of the strings themselves:
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ max() function in python
max() Function in Python- Scaler Topics
June 15, 2022 - The syntax of the max() function in Python is as follows: ... iterable: This parameter is an iterable that contains one or more items to be compared. For example, tuple, set, list, etc.
๐ŸŒ
Python Tutorial
pythontutorial.net โ€บ home โ€บ python built-in functions โ€บ python max() function
Python max(): Return the Maximum Item
September 15, 2022 - In this example, we pass a list of Employee objects and use the max() function to find the employee who has the highest salary.
๐ŸŒ
Career Karma
careerkarma.com โ€บ blog โ€บ python โ€บ python min and max: the ultimate guide
Python Min and Max: The Ultimate Guide | Career Karma
December 1, 2023 - The Python max() function returns the largest value in an iterable, such as a list. If a list contains strings, the last item alphabetically is returned by max(). ... You can see that you can specify individual values from which the highest ...