If the data is a single number, it can be made into a string and easily obtained by replacing it.
a, b = [1, 2, 3, 4, 3, 2], [1, 2, 3]
str_a = ''.join(map(str, a))
str_b = ''.join(map(str, b))
str_a.replace(str_b, '')
'432'
It's probably something like this.
I hope I didn't do the homework you should have done instead.
def list_diff_by_whole_match(target, criteria, returnRaw = False) :
# Simply ignorant, traverses all the way in index units.
for i in range(0, len(target)) :
matched = True
for j in range(0, len(criteria)) :
matched = matched and target[i + j] == criteria[j]
# We've confirmed that all the elements given to the criteria appear in order, so we make them None.
# (Caution not to del)
if matched :
for j in range(0, len(criteria)) :
target[i + j] = None
# Pulls out and returns only what you need, or returns the original as a result of the inspection.
return target if returnRaw else list(filter(None, target))
# Testing
v = [1,2,3,4,3,2,1,2,4,1,2,3,4]
w = [1,2,3]
print(list_diff_by_whole_match(v, w)) # [4, 3, 2, 1, 2, 4, 4]
© 2025 OneMinuteCode. All rights reserved.