On Tue, Apr 23, 2019 at 12:45 AM Grant Edwards
wrote:
> At the very top level _sometimes_ you want to have one single, global,
> try/except to catch all exceptions and handle the nofication and exit
> in a non-default way. For example: in a GUI application, it's
> possible that nobody will see
On 2019-04-20, Michael Torrie wrote:
> On 04/19/2019 04:01 AM, Sayth Renshaw wrote:
>> def max_try(listarg):
>> myMax = listarg[0]
>> try:
>> for item in listarg:
>> if item > myMax:
>> myMax = item
>> except TypeError:
>> print(f'Only
On 04/19/2019 04:01 AM, Sayth Renshaw wrote:
> def max_try(listarg):
> myMax = listarg[0]
> try:
> for item in listarg:
> if item > myMax:
> myMax = item
> except TypeError:
> print(f'Only numbers are supported, this entry "{item}" was not')
On 4/19/19 5:34 PM, MRAB wrote:
[snip]
How would you avoid comparing the initial max with list[0]? By slicing
the list? By using 'iter' and 'next'? Do you expect that doing either of
those to avoid a single comparison would make it faster? Is a comparison
very expensive?
You could, of
On 2019-04-20 00:24, DL Neil wrote:
On 20/04/19 4:41 AM, Rob Gaddi wrote:
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.
On 19Apr2019 05:38, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote:
On 4/19/19 4:01 AM, Sayth Renshaw wrote:
Now, what happens when the code is tested with various (different)
sets of test-data?
(remember the last question from my previous msg!?)
It fails on any list entry that
On 20/04/19 4:41 AM, Rob Gaddi wrote:
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
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
Sayth Renshaw writes:
>> Now, what happens when the code is tested with various (different) sets
>> of test-data?
>> (remember the last question from my previous msg!?)
>>
> It fails on any list entry that isn't a float or an int, giving a TypeError.
>
>> Once you are happy with the various
On 4/19/19 4:01 AM, Sayth Renshaw wrote:
Now, what happens when the code is tested with various (different) sets
of test-data?
(remember the last question from my previous msg!?)
It fails on any list entry that isn't a float or an int, giving a TypeError.
What if the *first* entry isn't a
> Now, what happens when the code is tested with various (different) sets
> of test-data?
> (remember the last question from my previous msg!?)
>
It fails on any list entry that isn't a float or an int, giving a TypeError.
> Once you are happy with the various test-runs, do you have any ideas
> 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
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
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.
--
https://mail.python.org/mailman/listinfo/python-list
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
>
> 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
On 2019-04-18, Rob Gaddi wrote:
> On 4/18/19 4:35 PM, Sayth Renshaw wrote:
>
>> This is where I have ended up. Without itertools and max its what I got
>> currently.
>>
>> def maximum(listarg):
>> myMax = listarg[0]
>> for item in listarg:
>> for i in
On 4/18/19 4:35 PM, Sayth Renshaw wrote:
It's still overly complicated.
This is where I have ended up. Without itertools and max its what I got
currently.
def maximum(listarg):
myMax = listarg[0]
for item in listarg:
for i in
> >
> It's still overly complicated.
>
This is where I have ended up. Without itertools and max its what I got
currently.
def maximum(listarg):
myMax = listarg[0]
for item in listarg:
for i in listarg[listarg.index(item)+1:len(listarg)]:
if myMax < i:
On 2019-04-18 08:39, Sayth Renshaw wrote:
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.
On Thu, Apr 18, 2019 at 5:41 PM Sayth Renshaw wrote:
>
> 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
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
On 18/04/19 4:10 PM, Sayth Renshaw wrote:
I have created a function that takes a list as an argument.
Without using itertools I want to compare each item in the list to find the max.
However instead of the max I keep getting the last item in the list. Where is
my logic wrong here?
...
wrote:
> >
> >
> > I have created a function that takes a list as an argument.
> > Without using itertools I want to compare each item in the list to find the
> > max.
> >
> > However instead of the max I keep getting the last item in the list. Where
> > is my logic wrong here?
> >
> > def
On Thu, Apr 18, 2019 at 9:31 AM Sayth Renshaw wrote:
>
>
> I have created a function that takes a list as an argument.
> Without using itertools I want to compare each item in the list to find the
> max.
>
> However instead of the max I keep getting the last item in the list. Where
> is my
I have created a function that takes a list as an argument.
Without using itertools I want to compare each item in the list to find the max.
However instead of the max I keep getting the last item in the list. Where is
my logic wrong here?
def maximum(listarg):
items = list(listarg)
26 matches
Mail list logo