Can I use - on lists (subtract) [code challenge lists]

I understand codeacademy’s solution. I’m not sure why my answer is not correct. Could you please take a look? Thank you in advance.

def remove_middle(lst, start, end):

new_lst = lst[start:end]
final_lst = lst - new_lst
return final_lst

print(remove_middle([4, 8, 15, 16, 23, 42], 1, 3))

We cannot subtract one list from another. Only concatenate two lists.

1 Like

Have you tried this?
If you do, you’ll see an error message (always read the error messages!!):

TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’

Interpretation: Although the + operator is supported (i.e., defined or “overloaded”) for lists, the - operator is not.

1 Like

Got it - didnt realize that. Thank you!

1 Like