What is a Nested Class ?

               A nested class (also called an inner class) is a class defined inside another class.

               The outer class usually represents a higher-level concept, and the inner class represents a part of it.


Syntax : 

Python
class OuterClass: class InnerClass: statements 


Example :

Python
class Outer: class Inner: def show(self): print("Inside Inner class") i = Outer.Inner() i.show() #output Inside Inner class


Accessing Inner Class from Outside :

Python
class Student: def __init__(self, name): self.name = name self.address = self.Address() def show(self): print("Name:", self.name) self.address.show_address() class Address: def show_address(self): print("City: Chennai") s = Student("Rahul") s.show() addr = Student.Address() addr.show_address()