list.index() like...but returning lists (for avoiding '0' on multiples hits)

Srinath Avadhanula srinathava_news at yahoo.com
Mon Dec 22 09:00:04 EST 2003


> but their results is not giving me the answer that i looking for...So, here i
> go...when i have myList = [2,4,2,0] ...myList.index(2) returns 0 (python
> 2.2)....There is a built-in function-method that returns [0,2]?
>

This works...

>>> a = [1,2,3,4]
>>> a[:2]
[1, 2]
>>>

Srinath





More information about the Python-list mailing list