{"id":3395,"date":"2020-06-26T10:31:36","date_gmt":"2020-06-26T05:01:36","guid":{"rendered":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/?p=3395"},"modified":"2021-06-14T16:00:32","modified_gmt":"2021-06-14T10:30:32","slug":"python-max-function","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/","title":{"rendered":"Using Python Max Function Like a Pro | Python max()"},"content":{"rendered":"\n<p>The main reason python is considered one of the easiest to learn and user-friendly languages because it offers <strong>different types of built-in functions<\/strong> that are super useful. One such function is the<strong> python max function<\/strong>. If you already use it in your program, you would know how many times it has made our life easy.\u00a0<\/p>\n\n\n\n<p><strong>Python max function is an inbuilt global function that is used to fetch the maximum value from a list, tuple, or dictionary. Sometimes, we need to fetch the highest values from the list and have a check on them. With the help <a href=\"https:\/\/www.pythonpool.com\/python-max-of-two-numbers\/\" target=\"_blank\" rel=\"noopener\">of max()<\/a>, we can do it easily without creating a new function.<\/strong><\/p>\n\n\n\n<p>Let&#8217;s understand how this works and some interesting use cases. Before that, let&#8217;s have a look at how it works.&nbsp;<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Usage_of_Python_Max_Function\" title=\"Usage&nbsp;of Python Max Function\">Usage&nbsp;of Python Max Function<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Syntax\" title=\"Syntax-&nbsp;\">Syntax-&nbsp;<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Examples_of_Python_Max_Function\" title=\"Examples of Python Max Function\u00a0\">Examples of Python Max Function\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Implementing_our_own_python_max_function\" title=\"Implementing our own python max function-&nbsp;\">Implementing our own python max function-&nbsp;<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Without_Recursion\" title=\"Without Recursion\">Without Recursion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#With_Recursion\" title=\"With Recursion-\">With Recursion-<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Some_Common_Errors_while_using_Python_Max_Function\" title=\"Some Common Errors while using Python Max Function\u00a0\">Some Common Errors while using Python Max Function\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Must_Read\" title=\"Must Read:\">Must Read:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-usage-of-python-max-function\"><span class=\"ez-toc-section\" id=\"Usage_of_Python_Max_Function\"><\/span>Usage&nbsp;of Python Max Function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When we want to find the <strong>largest element<\/strong> among the given elements or list of items, or maybe we want to find the list among many lists that contain the highest item, even we can find the string starting with the highest value alphabetically.&nbsp;&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-syntax\"><span class=\"ez-toc-section\" id=\"Syntax\"><\/span>Syntax-&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul><li><strong>max(iterable, *[, default=obj, key=func]) -&gt; value&nbsp;&nbsp;<\/strong><\/li><\/ul>\n\n\n\n<p>Here, iterable refers to object like list,string,tuple,etc.&nbsp;<\/p>\n\n\n\n<p><strong>default= If we pass an iterable without any values in the <a href=\"https:\/\/www.pythonpool.com\/python-list-max-index\/\" target=\"_blank\" rel=\"noopener\">max<\/a> function it will result in the following error-&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">max() arg is an empty sequence&nbsp;<\/pre>\n\n\n\n<p>So, we can pass a default parameter with any value we want. For example-&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(max(&#x5B;],default=&quot;No value&quot;)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">No value&nbsp;<\/pre>\n\n\n\n<p><strong>key<\/strong>= We will understand this parameter with an example.&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nlist1=&#x5B;&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;Z&quot;] \nprint(max(list1)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">c&nbsp;<\/pre>\n\n\n\n<p>In the example above,<strong> alphabetically \u2018Z\u2019 is the largest value<\/strong>, but as the <a href=\"https:\/\/www.pythonpool.com\/python-ascii-to-string\/\" target=\"_blank\" rel=\"noopener\">ASCII<\/a> value of \u2018Z\u2019 is lesser than that of \u2018c\u2019, we have got the output as \u2018c\u2019. To solve this problem, we will make every value in the same form using the key parameter. Let\u2019s see how-&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nlist1=&#x5B;&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;Z&quot;] \nprint (max(list1, key=str.lower)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Z&nbsp;<\/pre>\n\n\n\n<ul><li><strong>max (arg1, arg2, *args, *[, key=func]) -&gt; value&nbsp;<\/strong><\/li><\/ul>\n\n\n\n<p>When we do not need to pass the iterable and just the value in the arguments, we use this syntax.&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(max(1,2,3,4,5,6))\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">6&nbsp;<\/pre>\n\n\n\n<p>There is no default parameter and the key parameter is same as above.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-examples-of-python-max-function\"><span class=\"ez-toc-section\" id=\"Examples_of_Python_Max_Function\"><\/span><span class=\"has-inline-color has-vivid-red-color\">Examples of Python Max Function\u00a0<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul><li>Finding the highest value in a dictionary-&nbsp;<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndict1 = {'a':5,'b':1,'c':9,'d':2} \nprint(max (dict1.values())) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">9&nbsp;<\/pre>\n\n\n\n<ul><li>We are finding the largest value in the string.&nbsp;<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(max(&quot;ashwini&quot;)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">w&nbsp;<\/pre>\n\n\n\n<ul><li>Find the largest key in the dictionary&nbsp;<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nDict1={1:\u2019c\u2019,2:\u2019b\u2019,3:\u2019a\u2019} \nprint(max(Dict1))\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">3&nbsp;<\/pre>\n\n\n\n<ul><li>If we want to find the string with maximum length-&nbsp;<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(max(&quot;ashwini&quot;,&quot;mandani&quot;,&quot;max&quot;,&quot;function&quot;,key=len)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">function&nbsp;<\/pre>\n\n\n\n<ul><li>Suppose we want to find the list that has the highest element in it&nbsp;<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nlist1=&#x5B;1,2,3] \nlist2=&#x5B;3,4,5] \nlist3=&#x5B;5,6,1] \nprint(max(list1,list2,list3)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[5,6,1]<\/pre>\n\n\n\n<ul><li>Similarly, if we want to find the list with most number of elements &#8211;&nbsp;<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nlist1=&#x5B;1,2,3,5] \nlist2=&#x5B;3,4,5] \nlist3=&#x5B;5,6,1] \nprint(max(list1, list2, list3, key=len)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[1, 2, 3, 5]&nbsp;<\/pre>\n\n\n\n<ul><li>We can also apply max function on a pandas Series named series.&nbsp;<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(series)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">0 643.09&nbsp;\n1 656.22&nbsp;\n2 487.29&nbsp;\n3 1504.75&nbsp;\n4 1275.46&nbsp;\nName: size, dtype: float64&nbsp;<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(max(series)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1504.75&nbsp;<\/pre>\n\n\n\n<p>Now that we have learned how to use python max function with various data types. Let us implement our own max function.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-implementing-our-own-python-max-function\"><span class=\"ez-toc-section\" id=\"Implementing_our_own_python_max_function\"><\/span>Implementing our own python max function-&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-without-recursion\"><span class=\"ez-toc-section\" id=\"Without_Recursion\"><\/span>Without Recursion<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef max(list1):  \n   for i in range(0,len(list1)-1):   \n       for j in range(0,len(list1)-i-1): \n           if list1&#x5B;j] &gt; list1&#x5B;j+1]:  \n               list1&#x5B;j],list1&#x5B;j+1]=list1&#x5B;j+1],list1&#x5B;j]  \n   return list1&#x5B;-1] \n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1584\" height=\"436\" src=\"https:\/\/i1.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-56.png?fit=1024%2C282&amp;ssl=1\" alt=\"python max function\" class=\"wp-image-3398\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-56.png 1584w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-56-300x83.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-56-1024x282.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-56-768x211.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-56-1536x423.png 1536w\" sizes=\"(max-width: 1584px) 100vw, 1584px\" \/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nlist1=&#x5B;7, 5, 9, 6, 3]\nprint(max(list1))\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">9&nbsp;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-with-recursion\"><span class=\"ez-toc-section\" id=\"With_Recursion\"><\/span>With Recursion-<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let\u2019s look at how we can create our own max function with recursion. We can only pass a single list with multiple elements.&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef recursive_max(list1): \n   if list1&#x5B;1:]: \n       if list1&#x5B;0] &gt; rec_max(list1&#x5B;1:]): \n           return list1&#x5B;0] \n       else: \n           return rec_max(list1&#x5B;1:]) \n    elif not list1: \n       return \n   else: \n       return list1&#x5B;0] \n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1586\" height=\"628\" src=\"https:\/\/i0.wp.com\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-54.png?fit=1024%2C405&amp;ssl=1\" alt=\"python max function\" class=\"wp-image-3396\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-54.png 1586w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-54-300x119.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-54-1024x405.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-54-768x304.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/image-54-1536x608.png 1536w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nlist1 = &#x5B;12, 56, 23, 80]\nprint(recursive_max(list1))\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">80&nbsp;<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nlist1 = &#x5B;'a','b','c','d'] \nprint(recursive_max(list1)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">d&nbsp;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-some-common-errors-while-using-python-max-function\"><span class=\"ez-toc-section\" id=\"Some_Common_Errors_while_using_Python_Max_Function\"><\/span>Some Common Errors while using Python Max Function\u00a0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>TypeError<\/strong>&#8211; This is a very common error we face. This error generally occurs when in the max function we pass incompatible data types with each other like string and integer or float and string.&nbsp;<\/p>\n\n\n\n<p>For example-&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(max(&quot;ashwin&quot;,1))\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">TypeError- '&gt;' not supported between instances of 'int' and 'str'&nbsp;<\/pre>\n\n\n\n<p>Also, if we don\u2019t pass any value in the max function, we get this error. For this we use default parameter.&nbsp;&nbsp;<\/p>\n\n\n\n<p>The Complimentary method of python max function is <a href=\"https:\/\/www.pythonpool.com\/python-min\/\" target=\"_blank\" rel=\"noopener\">min function<\/a>, which is used to find the minimum value.\u00a0<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nprint(min(&#x5B;1,2,3,4,5])) \n<\/pre><\/div>\n\n\n<p id=\"block-a7341d98-d571-49eb-8df6-c854603ccca5\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1&nbsp;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-must-read\"><span class=\"ez-toc-section\" id=\"Must_Read\"><\/span>Must Read:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul><li><a href=\"https:\/\/www.pythonpool.com\/python-lowercase\/\">How to Convert String to Lowercase in<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/square-root-in-python\/\">How to Calculate Square Root<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/python-user-input\/\">User Input | Input () Function | Keyboard Input<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/python-book\/\">Best Book to Learn Python<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>The time complexity of the python max function is O(n)<\/strong>. Unlike max functions in other programming languages like C++, it offers a variety of uses. We can apply it on the string, which is not possible in other languages. These types of built-in functions make python a great language.<\/p>\n\n\n\n<p>Try to run the programs on your side and let me know if you have any queries.<\/p>\n\n\n\n<p><strong><em>Happy Coding!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The main reason python is considered one of the easiest to learn and user-friendly languages because it offers different types of built-in functions that are &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Using Python Max Function Like a Pro | Python max()\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/#more-3395\" aria-label=\"More on Using Python Max Function Like a Pro | Python max()\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":3403,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15],"tags":[1185,1172,1181,1187,1173,1170,1179,1175,1171,1184,1174,1177,1186,1182,1176,1178,1180,1183],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v22.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Python Max Function Like a Pro | Python max() - Python Pool<\/title>\n<meta name=\"description\" content=\"Python max function is used to find the greatest element in an iterable or in a string. If the values are strings, an alphabetical comparison is done.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/python-max-function\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Python Max Function Like a Pro | Python max()\" \/>\n<meta property=\"og:description\" content=\"The main reason python is considered one of the easiest to learn and user-friendly languages because it offers different types of built-in functions that\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-max-function\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-26T05:01:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-14T10:30:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1002\" \/>\n\t<meta property=\"og:image:height\" content=\"605\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ashwini Mandani\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashwini Mandani\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/\"},\"author\":{\"name\":\"Ashwini Mandani\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\"},\"headline\":\"Using Python Max Function Like a Pro | Python max()\",\"datePublished\":\"2020-06-26T05:01:36+00:00\",\"dateModified\":\"2021-06-14T10:30:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/\"},\"wordCount\":701,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg\",\"keywords\":[\"find max and min in a list python without inbuilt function\",\"find max of function python\",\"how to create a function to find min and max in python\",\"how to find maximum in list without max function python\",\"how to use max function in python\",\"max function in python\",\"max function in python 3\",\"max function python\",\"max function python 3\",\"max function python example\",\"max function python w3\",\"max python function\",\"max sum function list python\",\"python max function example\",\"python max function key\",\"python max() function\",\"recursive max function python\",\"script to get the max value of a function python\"],\"articleSection\":[\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/python-max-function\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/\",\"url\":\"https:\/\/www.pythonpool.com\/python-max-function\/\",\"name\":\"Using Python Max Function Like a Pro | Python max() - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg\",\"datePublished\":\"2020-06-26T05:01:36+00:00\",\"dateModified\":\"2021-06-14T10:30:32+00:00\",\"description\":\"Python max function is used to find the greatest element in an iterable or in a string. If the values are strings, an alphabetical comparison is done.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/python-max-function\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg\",\"width\":1002,\"height\":605,\"caption\":\"python max function\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/python-max-function\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Python Max Function Like a Pro | Python max()\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\",\"name\":\"Ashwini Mandani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/efd3e2763a755a226df4479ad87a5464?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/efd3e2763a755a226df4479ad87a5464?s=96&d=wavatar&r=g\",\"caption\":\"Ashwini Mandani\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Using Python Max Function Like a Pro | Python max() - Python Pool","description":"Python max function is used to find the greatest element in an iterable or in a string. If the values are strings, an alphabetical comparison is done.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/","og_locale":"en_US","og_type":"article","og_title":"Using Python Max Function Like a Pro | Python max()","og_description":"The main reason python is considered one of the easiest to learn and user-friendly languages because it offers different types of built-in functions that","og_url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/","og_site_name":"Python Pool","article_published_time":"2020-06-26T05:01:36+00:00","article_modified_time":"2021-06-14T10:30:32+00:00","og_image":[{"width":1002,"height":605,"url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg","type":"image\/jpeg"}],"author":"Ashwini Mandani","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Ashwini Mandani","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/"},"author":{"name":"Ashwini Mandani","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056"},"headline":"Using Python Max Function Like a Pro | Python max()","datePublished":"2020-06-26T05:01:36+00:00","dateModified":"2021-06-14T10:30:32+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/"},"wordCount":701,"commentCount":2,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg","keywords":["find max and min in a list python without inbuilt function","find max of function python","how to create a function to find min and max in python","how to find maximum in list without max function python","how to use max function in python","max function in python","max function in python 3","max function python","max function python 3","max function python example","max function python w3","max python function","max sum function list python","python max function example","python max function key","python max() function","recursive max function python","script to get the max value of a function python"],"articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/","url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/","name":"Using Python Max Function Like a Pro | Python max() - Python Pool","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg","datePublished":"2020-06-26T05:01:36+00:00","dateModified":"2021-06-14T10:30:32+00:00","description":"Python max function is used to find the greatest element in an iterable or in a string. If the values are strings, an alphabetical comparison is done.","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg","contentUrl":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/06\/Capture-8.jpg","width":1002,"height":605,"caption":"python max function"},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/python-max-function\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Using Python Max Function Like a Pro | Python max()"}]},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/twitter.com\/pythonpool","https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056","name":"Ashwini Mandani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/secure.gravatar.com\/avatar\/efd3e2763a755a226df4479ad87a5464?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/secure.gravatar.com\/avatar\/efd3e2763a755a226df4479ad87a5464?s=96&d=wavatar&r=g","caption":"Ashwini Mandani"}}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3395"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=3395"}],"version-history":[{"count":10,"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3395\/revisions"}],"predecessor-version":[{"id":24520,"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3395\/revisions\/24520"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/3403"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=3395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=3395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=3395"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20240926031929\/https:\/\/api.w.org\/{rel}","templated":true}]}}