query on python list

muttu2244 at yahoo.com muttu2244 at yahoo.com
Tue Dec 27 22:29:12 EST 2005


hi all
am searching for a key in a list, am using

  Found = 0
  for item in list:
         if not key == item:
             Found = 0
         elif key == item:
             Found =1

Now based on the Found value i ll manipulate the list.
but whenever the "key and item" doesnt match it makes "Found = 0", even
though i have an item that matches the key, but it overwrites the Found
variable to 0, in the next loop when "key ! = item", and hence all my
calculations are going wrong,
If i find a key in my list, some how the variable "Found " should be
1,till it comes out of the loop.

How can i do that.

thanks in advance
yogi




More information about the Python-list mailing list