From 02652531dd3b6e672f0e9e4332776fab1dc308d0 Mon Sep 17 00:00:00 2001 From: shruti-goswami <62581739+shruti-goswami@users.noreply.github.com> Date: Sun, 2 Feb 2025 12:48:09 +0530 Subject: [PATCH] Updated error in except block for removal of id attribute The error inremova except block to catch the exception thrown after removal of id attribute should be AttributeError and not NameError as observed in python 3.13.1 --- Basics/Exercise/16_class_and_objects/16_class_and_objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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..7a061da1 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 @@ -17,11 +17,11 @@ def display(self): # Deleting the object itself try: print(emp.id) -except NameError: +except AttributeError: print("emp.id is not defined") 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")