> On 19/04/19 7:23 PM, Sayth Renshaw wrote:
In English:
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.
Criticism: (because this does NOT match the code, below!)
- should the algorithm "Compare each subsequent integer to the first" or
is the comparison with 'the current largest', ie 'the largest so-far'?
NB IIRC this was (likely) why it was suggested that you explain the
method in English, first!
In code:
def maxitwo(listarg):
myMax = listarg[0]
for item in listarg:
if item > myMax:
myMax = item
return myMax
Well done!
Now, what happens when the code is tested with various (different) sets
of test-data?
(remember the last question from my previous msg!?)
Once you are happy with the various test-runs, do you have any ideas for
making the code more efficient?
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list