class Student:
def __init__(self,name,age, gender,major):
self.name=name
self.age=age
self.gender=gender
self.major=major
def __del__(self):
print("The student records has been deleted successfully.")
The series of output is as follows:
I typed this code in IDLE and then run the module. After running the module, I created an object called "Student1" and pass the required values, then checked it. By calling del method the object was destroyed and thus trying to access any state of that previous object gives the output as "Student1 is not defined."