Python | Pretty Print a dictionary with the meaning of the dictionary

Method: Using Loops
We simply iterate over each element of the dictionary and its corresponding values ​​using a loop.

# Python3 code to demonstrate how it works
# Pretty Print a dictionary with the dictionary value
# Using loops

 
# initializing dictionary

test_dict = { `gfg` : { `rate` : 5 , ` remark` : `good` }, `cs` : { ` rate` : 3 }}

 
# print the original dictionary

print ( "The original dictionary is:" +   str (test_dict))

 
# using loops for Pretty Print

print ( "The Pretty Print dictionary is:" )

for sub in test_dict:

  print (sub)

  for sub_nest in test_dict [sub]:

  print (sub_nest, `: ` , test_dict [sub] [sub_nest])

Output:

 The original dictionary is: {`gfg`: { `remark`:` good`, `rate`: 5},` cs`: {`rate`: 3}} The Pretty Print dictionary is: gfg remark: good rate: 5 cs rate: 3