#!/usr/bin/env python3
#=====================================================================================
# Python dictionary with nested dictionaries
# Python dictionary with nested lists
#=====================================================================================
print("Content-Type: text/html \n")     #http header with newline char (required for web)
print('<pre>')                          #to produce better display on the web 

stuff1 = {'a':100, 'b':200, 'c':300, 'd':{'d1':410, 'd2':420}, 'e':500 }

stuff2 = {'a': ['a1','a2','a3','a4','a5','a6','a7','a8'], 
          'b': ['b1','b2','b3','b4','b5','b6','b7','b8'], 
          'c': ['c1','c2','c3','c4','c5','c6','c7','c8'] }

print('Printing a dictionary within a dictionary :', stuff1)
print("Printing the content of element 'd' ..... :", stuff1['d'])
print()

print('Printing dictionary containing lists .... :', stuff2)
print('Printing the first element only ......... :', stuff2['a'])
print('Printing the second element only ........ :', stuff2['b'])
print('Printing the third element only ......... :', stuff2['c'])
print("Printing element 'b6' only .............. :", stuff2['b'][5])
print('Printing the length of the dictionary ... :', len(stuff2),      '<-- notice it is 3')
print("Printing the length of element 'a' ...... :", len(stuff2['a']))

new_list = ['d1','d2','d3','d4','d5','d6','d7','d8']
stuff2['d'] = new_list 

print('Adding a new list to the dictionary ..... :', new_list) 
print('Printing dictionary containing lists .... :', stuff2)
print()