I need to write a recursive function that receives 2 lists and returns a new list with the subtraction of the elements of the first ones, for example:
>>> subtrai([2, 3, 4, 5], [2, 3])
[4, 5]
I know that I need to know if an element of the 1st list belongs to the 2nd: in the case of belonging this element can not be part of the result, otherwise it belongs.
The problem is that I can not use the remove () function ...
At this point I have the following code
elem = []
if elem in l1 and l2:
return list(l1-l2)
else:
return l1
This code returns me only list 1, I can not figure out what I'm doing wrong
Thank you in advance for your help