Write a program to Pretty Print a dictionary with dictionary values.


Topic: Write a program to Pretty Print a dictionary with dictionary values.

Solution

test_dict = {'tsai' : {'rate' : 5, 'remark' : 'good'}, 'cs' : {'rate' : 3}} 
print("The Pretty Print dictionary is : ") 
for sub in test_dict: 
    print(f"\n{sub}") 
    for sub_nest in test_dict[sub]: 
        print(sub_nest, ':', test_dict[sub][sub_nest])



List all Python Programs