Skip to content

Commit 3cbba72

Browse files
Update delattr.md
Fixed heading structure for added examples for delattr()
1 parent cd4356d commit 3cbba72

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docs/builtin/delattr.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ Python delattr() built-in function
1919
## Examples
2020

2121
```python
22-
# Example 1
2322
class Person:
2423
def __init__(self, name, age):
2524
self.name = name
2625
self.age = age
2726

28-
person = Person("John", 30)
29-
delattr(person, 'age')
30-
print(person.__dict__) # Output: {'name': 'John'}
27+
>>> person = Person("John", 30)
28+
>>> delattr(person, 'age')
29+
>>> person.__dict__
30+
# {'name': 'John'}
3131

32-
# Example 2
3332
class Car:
3433
def __init__(self, make, model):
3534
self.make = make
3635
self.model = model
3736

38-
car = Car("Toyota", "Corolla")
39-
try:
40-
delattr(car, 'year')
41-
except AttributeError as e:
42-
print(f"Error: {e}") # Output: Error: 'Car' object has no attribute 'year'
37+
>>> car = Car("Toyota", "Corolla")
38+
>>> try:
39+
... delattr(car, 'year')
40+
... except AttributeError as e:
41+
... print(f"Error: {e}")
42+
# Error: 'Car' object has no attribute 'year'
4343
```
4444
<!-- remove this tag to start editing this page -->
4545
<empty-section />

0 commit comments

Comments
 (0)