Function to determine list max without itertools

Rob Gaddi rgaddi at highlandtechnology.invalid
Fri Apr 19 12:41:09 EDT 2019


On 4/19/19 12:23 AM, Sayth Renshaw wrote:
> On Friday, 19 April 2019 17:01:33 UTC+10, Sayth Renshaw  wrote:
>> Set the first item in the list as the current largest.
>>          Compare each subsequent integer to the first.
>>                  if this element is larger, set integer.
> 
> def maxitwo(listarg):
>      myMax = listarg[0]
>      for item in listarg:
>          if item > myMax:
>              myMax = item
> 
>      return myMax
> 
> Sayth
> 

When you understand what it is you intend to write (barring DL Neil's 
comments), and THEN write it, you write the correct thing.  Thus endith 
the lesson.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.


More information about the Python-list mailing list