Re: [Tutor] simple list query

2005-01-03 Thread Gonçalo Rodrigues
Patrick Hall wrote: Hi Dave, I have a list consisting of about 250 items, I need to know if a particular item is in the list. I know this is better suited to a dictionary but thats not the way it ended up ;-) I could do a for loop to scan the list & compare each one, but I have a suspission that

Re: [Tutor] simple list query

2005-01-02 Thread Alan Gauld
> You might want to try: > > x in list Blush, I forgot about 'in'. And being in C it should be faster than the sort/loop combination. Silly me... :-( Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] simple list query

2005-01-02 Thread Alan Gauld
> I have a list consisting of about 250 items, I need to know if a > particular item is in the list. I know this is better suited to a > dictionary but thats not the way it ended up ;-) > > I could do a for loop to scan the list & compare each one, but I have a > suspission that there is a better

Re: [Tutor] simple list query

2005-01-02 Thread Dave S
Patrick Hall wrote: Hi Dave, I have a list consisting of about 250 items, I need to know if a particular item is in the list. I know this is better suited to a dictionary but thats not the way it ended up ;-) I could do a for loop to scan the list & compare each one, but I have a suspis

Re: [Tutor] simple list query

2005-01-02 Thread Patrick Hall
Hi Dave, > I have a list consisting of about 250 items, I need to know if a > particular item is in the list. I know this is better suited to a > dictionary but thats not the way it ended up ;-) > I could do a for loop to scan the list & compare each one, but I have a > suspission that there is

Re: [Tutor] simple list query

2005-01-02 Thread Bill Kranec
You might want to try: x in list this will return true if, for example, list = [x,y,z,w], false if list = [y,y,y,y] Bill Dave S wrote: OK simple query, I have a list consisting of about 250 items, I need to know if a particular item is in the list. I know this is better suited to a dictionary

[Tutor] simple list query

2005-01-02 Thread Dave S
OK simple query, I have a list consisting of about 250 items, I need to know if a particular item is in the list. I know this is better suited to a dictionary but thats not the way it ended up ;-) I could do a for loop to scan the list & compare each one, but I have a suspission that there is