World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Garbage collection is a very important aspect of any good programming language. Likewise, Python lets us delete a lot of stuff, including objects.
To delete an object in Python, we use the ‘del’ keyword. A when we try to refer to a deleted object, it raises NameError.
>>> del orange >>> orange ------------------------------------------------------------------------------------------------------ Traceback (most recent call last): File “<pyshell#729>”, line 1, in <module> orange NameError: name ‘orange’ is not defined -------------------------------------------------------------------------------------------------------