Is there anyway to compare lists or check to see how many of the objects in one list are the same as the other list?
eg:
L1 = [dog, cat, john, moo]
L2 = [dog, cow, moo, stuff]
there is two of the same "things" in it
I'm trying to write a program to decide what option would be best sort of thing.
thanks.
sorry bout spelling and uh my terminology
This is what i have so far but the very end is what i need help with.
# testing for list relativy thing
user_input = ["three", "four", "five", "six", "seven", "eight", "nine", "ten","one", "two"]
user_input1 = user_input
list1 = [["1",["one"]], # Each nest is one "thing"
["2",["two", "one"]],
["3",["one", "two", "three"]],
["4",["one", "two", "three", "four"]],
["5",["one", "two", "three", "four", "five"]],
["6",["one", "two", "three", "four", "five", "six"]],
["7",["one", "two", "three", "four", "five", "six", "seven"]],
["---------RELCHECK ERROR---------",["dog","horse"]],
["8",["one", "two", "three", "four", "five", "six", "seven", "eight"]],
["9",["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]],
["10",["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"]] ]
relevant_facts =[]
a = 0
b = 0
c = 0
d = 0
e = 0
rellist = []
search_no = 0
facts_length = len(list1) # Checks how many things there are
input_length = len(user_input1) - 1
relcheck=0
# Find all relevant things
while relcheck < facts_length: # Make sure Its within the user_input range.
keysize = len(list1[a][1]) - 1
if list1[a][1][b] in user_input:
rellist.append(list1[a])
b = 0
a += 1
relcheck += 1
print rellist
else:
if b < keysize:
b +=1
else:
b = 0
a += 1
relcheck += 1
# Choose most relevant
# This is the hard bit for me
relsort = 0
rellistlen = len(rellist) - 1
while relsort < rellistlen:
if rellist[c][1][d] in user_input
Thanks