title: Trying to decrypt and print out a text file I encrypted in same program
body: <p>So I finally figured out how to read and encrypt a text file. Now I have to create a second program that opens the encrypted file then display its decrypted contents on the screen. I was good until I had to reverse and figure out how print out the key in the dictionary. Any help is great, TIA!</p>
  
  <p>here is my code:</p>
  
  <pre><code>    dictionary = {'A':'D', 'B':'E', 'C':'F', 'D':'G', 'E':'H', 
              'F':'I', 'G':'J', 'H':'K','I':'L',\
              'J':'M', 'K':'N', 'L':'O', 'M':'P', 'N':'Q', 'O':'R', 
              'P':'S', 'Q':'T', 'R':'U',\
              'V':'Y', 'W':'Z', 'X':'A', 'Y':'B', 'Z':'C'}
      def encrypt_file():
          file = open('texttoencrypt.txt', 'r')
          new_file = open('encrypted_text.txt', 'w')
  
          while True:
              char = file.read(1)
               if not char:
                  break
              char = char.upper()
              if char in dictionary.keys():
                   new_char = dictionary[char]
                   new_file.write(new_char)
              else:
                   new_file.write(char)
  
           file.close()
           new_file.close()
  
      encrypt_file()
  
      def decrypt_file():
          encrypted = open('encrypted_text.txt', 'r')
          decrypt = ''
          while True:
              char = encrypted.read(1)
              if not char:
                  break
              for key, values in dictionary.items():
                   if char in values:
                       decrypt+= key
                   else:
                       decrypt += char
           print(decrypt)
           encrypted.close()
  </code></pre>