From 983789e01ee086ee0460db455c30db414969f74c Mon Sep 17 00:00:00 2001 From: tahirpukhta <152134239+tahirpukhta@users.noreply.github.com> Date: Tue, 19 Dec 2023 08:38:33 +0530 Subject: [PATCH] Update 16_class_and_objects.py I just replaced the NameError with the Attribute error. --- .../16_class_and_objects/16_class_and_objects.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Basics/Exercise/16_class_and_objects/16_class_and_objects.py b/Basics/Exercise/16_class_and_objects/16_class_and_objects.py index 4893cabc..f5077170 100644 --- a/Basics/Exercise/16_class_and_objects/16_class_and_objects.py +++ b/Basics/Exercise/16_class_and_objects/16_class_and_objects.py @@ -8,20 +8,19 @@ def display(self): print(f"ID: {self.id} \nName: {self.name}") -# Creating a emp instance of Employee class +# Creating an emp instance of the Employee class emp = Employee(1, "coder") emp.display() # Deleting the property of object del emp.id -# Deleting the object itself try: print(emp.id) -except NameError: +except AttributeError: print("emp.id is not defined") - +# Deleting the object itself del emp try: emp.display() # it will gives error after deleting emp except NameError: - print("emp is not defined") \ No newline at end of file + print("emp is not defined")