educative.io

Educative

Stubborn del operation

def del():
print(“Got deleted”)

a=[1,2,3]
del(a)

how to make sure that the del function got invoked without creating the class?
or
Why “Got deleted” is not getting print as everything is an object in python and it won’t override the global/parent del method?

If you run this code, you will get an invalid syntax error. Why are you trying to use the same name as the inbuilt function to delete an item? If you replace the name with another generic name, i.e., delete, this should work fine.