Formatting containers using format() in Python
Let us see how to format containers that were accessed through __getitem__ or getattr() using the format() method in Python.
Accessing containers that support __getitem__
a) For Dictionaries
Bill Gates Steve Jobs
f[Microsoft] is replaced by Bill Gates and f[Apple] is replaced by Steve Jobs.
b) For lists
Accessing attributes on objects that support getattr()
a) For Class
p.language is replaced by Python as language is an attribute of Program
Accessing the nested structure