Writing a code to save a dictionary format