@@ -16,6 +16,36 @@ Python getattr() built-in function
1616 </base-disclaimer-content >
1717</base-disclaimer >
1818
19- <!-- remove this tag to start editing this page-->
20- <empty-section />
21- <!-- remove this tag to start editing this page-->
19+ ##Syntax
20+
21+ ``` python
22+ getattr (object , name)
23+ ```
24+ or
25+ ``` python
26+ getattr (object , name, default)
27+ ```
28+ -` object ` : The object whose attribute you want to access.
29+
30+ -` name ` : The name of the attribute you want to retrieve.
31+
32+ -` default ` : (Optional) The value to be returned if the attribute is not found. If not provided,` None ` is returned.
33+
34+ ##Example
35+
36+ ``` python
37+ class Example :
38+ attribute= " Hello, World!"
39+
40+ # Creating an instance of the class
41+ obj= Example()
42+
43+ # Using getattr to access the attribute
44+ value= getattr (obj,' attribute' ,' Nothing found' )
45+
46+ print (value)# Output: Hello, World!
47+
48+ # If the 'attribute' does not exist then 'Nothing found' will be printed.
49+ ```
50+
51+