Function to determine list max without itertools
flebber.crue at gmail.com
Thu Apr 18 03:39:51 EDT 2019
Thank you for the advice everyone.
> The first thing to try is find every place where you update myMax, and
This was actually where I was going wrong. I was setting max but then overwriting it with item. Then kept checking item only to return myMax.
I went looking for other solutions as I thought I must be well off the path in the shrubs but I was actually close.
This is how I ended up. There may be better solutions but this works.
items = list(listarg)
myMax = items
for item in items:
for i in items[items.index(item)+1:len(items)]:
if myMax < i:
myMax = i
if __name__ == "__main__":
More information about the Python-list