【每日一题20220331】列表运算

def solution(nums_a: list, nums_b: list):
    # your code here
    for num in nums_a[::-1]:
        if num in nums_b:
            nums_a.remove(num)

    return nums_a


assert solution([1, 1, 2 ,3 ,1 ,2 ,3 ,4], [1, 3]) == [2, 2, 4]
assert solution([8, 2, 7, 2, 3, 4, 6, 5, 4, 4, 1, 2 , 3], [2, 4, 3]) == [8, 7, 6, 5, 1]
assert solution([1, 1, 2 ,3 ,1 ,2 ,3 ,4, 4, 3 ,5, 6, 7, 2, 8], [1, 3, 4, 2]) == [5, 6 ,7 ,8]
def solution(nums_a: list, nums_b: list)-> list:
    return [i for i in nums_a if i not in nums_b]

assert solution([1, 1, 2 ,3 ,1 ,2 ,3 ,4], [1, 3]) == [2, 2, 4]
assert solution([8, 2, 7, 2, 3, 4, 6, 5, 4, 4, 1, 2 , 3], [2, 4, 3]) == [8, 7, 6, 5, 1]
assert solution([1, 1, 2 ,3 ,1 ,2 ,3 ,4, 4, 3 ,5, 6, 7, 2, 8], [1, 3, 4, 2]) == [5, 6 ,7 ,8]