On 19/04/19 5:22 PM, Sayth Renshaw wrote:


In English rather than Python, how do you find the maximum element in a
list?

--
Rob Gaddi, Highland Technology

Get first 1 item in the list and compare it to the rest. If it is larger than 
rest its the max. However if another list member is larger it replaces the 
first item and comparison continues.


A good first effort!

Is it sufficiently-detailed to say "compare it to the rest"? Is it being compared with ALL of the other elements of the list at once?


How about this outline:

        Set the first item in the list as the current largest.
        Compare ...
                if this element is larger, set ...

How could we fill in the gaps (...) of that description?


Also, what types of data are you expecting as elements within the list?
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to