On Apr 5, 6:37 pm, "John Machin" <[EMAIL PROTECTED]> wrote:
>>> help(list.index)
> Help on method_descriptor:
>
> index(...)
>     L.index(value, [start, [stop]]) -> integer -- return first index
> of value
>
> I look forward to your next version.

Great point! I was assuming the temp variable space was static but the
pointer to the start of the list was moving-> shame on me (what
language is this now ;)!

Couldn't resist the temptation to just collect all of the locations as
I traversed

m = [2,9,1,5,6,3,1,1,9,2]
f = 1        #What we're looking for
location = 0 #Start at beginning of list
fIndexs = []
while 1:
   try:
      location = m.index(f,location) + 1
      fIndexs.append(location-1)
   except ValueError:
      break

print("Last location = %d" % fIndexs[-1])
print("All Items = %s" % fIndexs)

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to