query on python list

muttu2244 at yahoo.com muttu2244 at yahoo.com
Wed Dec 28 04:59:26 CET 2005

hi tim
thanks for the help
acutally i dint tell u the whole problem
i have list of lists, for ex

list1 =[ ['a','b','c','d','e'] , ['1','2','3','4'] ,  ['A','B','C','D']

and another list

list2 = ['1','2','5',4]

now am searching the items of list2 in list1 as below

Found = True
for i in list1:
    for j in i:
        if not list2[1] == j or not list2[2] == j:
                if not list2[0] == j:
                    Found = False
                elif list2[0] == j:
                    Found = True

now though it finds the the key in between and sets the "Found=True",
but later in the next list of if one item doesnt match it sets again
Found = False

i hope am clear this time

how to keep the Found = True for always if at all i find the item even

thanks again in advance

More information about the Python-list mailing list