Function to determine list max without itertools

Sayth Renshaw flebber.crue at gmail.com
Fri Apr 19 03:23:15 EDT 2019


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



More information about the Python-list mailing list