Re: Finding the first index in a list greater than a particular value

2016-08-15 Thread Michael Selik
On Mon, Aug 15, 2016 at 2:01 AM Jussi Piitulainen < jussi.piitulai...@helsinki.fi> wrote: > There is a tradition of returning -1 when no valid index is found. > Sometimes it's better to break with tradition. Raise a ValueError. No silent errors, and all that Zen. -- https://mail.python.org/mailm

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread Jussi Piitulainen
Atri Mahapatra writes: > I have a list of dictionaries which look like this: > [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, > 'Length': 40.0, 'Object': 'Object2'}.. so on till 10] > > I would like to find the first index in the list of dictionaries whose > length is

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread Michael Selik
On Sun, Aug 14, 2016 at 2:21 PM Atri Mahapatra wrote: > I have a list of dictionaries which look like this: > [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, > 'Length': 40.0, 'Object': 'Object2'}.. so on till 10] > > I would like to find the first index in the list of d

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread MRAB
On 2016-08-14 19:40, Atri Mahapatra wrote: On Monday, 15 August 2016 00:03:59 UTC+5:30, MRAB wrote: On 2016-08-14 19:17, Atri Mahapatra wrote: > I have a list of dictionaries which look like this: > [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, 'Length': 40.0, 'Object':

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread Atri Mahapatra
On Monday, 15 August 2016 00:03:59 UTC+5:30, MRAB wrote: > On 2016-08-14 19:17, Atri Mahapatra wrote: > > I have a list of dictionaries which look like this: > > [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, > > 'Length': 40.0, 'Object': 'Object2'}.. so on till 10] > >

Re: Finding the first index in a list greater than a particular value

2016-08-14 Thread MRAB
On 2016-08-14 19:17, Atri Mahapatra wrote: I have a list of dictionaries which look like this: [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, 'Length': 40.0, 'Object': 'Object2'}.. so on till 10] I would like to find the first index in the list of dictionaries whose l

Finding the first index in a list greater than a particular value

2016-08-14 Thread Atri Mahapatra
I have a list of dictionaries which look like this: [{'Width': 100, 'Length': 20.0, 'Object': 'Object1'}, {'Width': 12.0, 'Length': 40.0, 'Object': 'Object2'}.. so on till 10] I would like to find the first index in the list of dictionaries whose length is greater than a particular value f

Re: Index in a list

2012-10-17 Thread Hans Mulder
On 17/10/12 12:10:56, Anatoli Hristov wrote: > I'm trying to index a text in a list as I'm importing a log file and > each line is a list. > > What I'm trying to do is find the right line which contains the text > User : and take the username right after the text "User :", but the > list.index("(U

Re: Index in a list

2012-10-17 Thread Anatoli Hristov
Thanks a lot this solved my issue:) Regards Anatoli On Wed, Oct 17, 2012 at 12:23 PM, Chris Angelico wrote: > On Wed, Oct 17, 2012 at 9:10 PM, Anatoli Hristov wrote: >> Hello, >> >> I'm trying to index a text in a list as I'm importing a log file and >> each line is a list. >> >> What I'm tryi

Re: Index in a list

2012-10-17 Thread Chris Angelico
On Wed, Oct 17, 2012 at 9:10 PM, Anatoli Hristov wrote: > Hello, > > I'm trying to index a text in a list as I'm importing a log file and > each line is a list. > > What I'm trying to do is find the right line which contains the text > User : and take the username right after the text "User :", bu

Index in a list

2012-10-17 Thread Anatoli Hristov
Hello, I'm trying to index a text in a list as I'm importing a log file and each line is a list. What I'm trying to do is find the right line which contains the text User : and take the username right after the text "User :", but the list.index("(User :") is indexing only if all the text matching