the below code attempts to scan all elements of mag for all elements of note. If all UNIQUE elements of note can be found in mag, then it should print YES .. else it should print NO. The check for elements is supposed to be case sensitive.
mag =['two', 'times', 'three', 'is', 'not', 'four', 'two']
note =['two', 'times', 'two', 'is', 'four']
r = ""
x=[]
for i in mag:
for j in note:
if j in i and j not in x:
x.append(j)
if len(x)==len(note):
r = "YES, all note elements can be found in mag"
else:
r = "NO, all note elements cannot be found in mag"
print(r)
print (" ".join(map(str, x)))
When i run the code, i get r = "NO, all n elements cannot be found in mag" .. but that should not be the case because the frequency of element "two" is 2 in both list(mag) and list(note)
What I want to achieve: I want to compare whether each unique element in note can be found in mag. e.g. if mag=["a", "b", "c", "d"] and note = ["b", "a", "c"] .. it will return TRUE. but if mag=["a", "b", "c", "d"] and note = ["b", "a", "a" "c"] then it return false because "a" occurs twice in note but once in mag