I am new to Python and to coding, and I am running in to a challenge. I am trying to remove all values from "list_a" that are present in "list_b." The inputs passed through the function must be lists, they can't be any other data type.
For example, [1,2,2,2,3], [2] should return [1, 3].
My attempt is below, but it returns [1, 2, 3] which is wrong. I'm stuck and would appreciate some help on how to do this the right way, please.
def changeup(list_a, list_b):
for i in list_b:
for k in list_a:
if k == i:
list_a.remove(k)
return list_a
changeup([1,2,2,2,3],[2])
#This is returning [1, 2, 3]. It should be returning [1, 3]. Not sure why?