title: Problems finding key/appending multiple values to a key in dictionary (python)
body: <p>I am trying to make a dictionary that will save a value to a key and if the key is already existing, the value will be appended to the key to make a list of values. I am using python 3 so the dict.has_key method has deprecated, can someone please point me in the right direction?</p>
  
  <p>Binary.txt: </p>
  
  <pre><code>N = N D
  N = D
  D = 0
  D = 1
  
  
  
  import sys
  import string
  
  #default length of 3
  stringLength = 3
  
  #get last argument of command line(file)
  filename1 = sys.argv[-1]
  
  
  #get a length from user
  try:
      stringLength = int(input('Length? '))
      filename = input('Filename: ')
  except ValueError:
      print("Not a number")
  
  #checks
  print(stringLength)
  print(filename)
  
  def str2dict(filename="Binary.txt"):
      result = {}
      with open(filename, "r") as grammar:
          #read file 
          lines = grammar.readlines()
          count = 0
          #loop through
          for line in lines:
              #append info 
              print(line)
              line = line.rstrip('\n')
  
              if line[0] in result:
                  result[line[0]].append(line.split('=')[1])
  
              else: 
  
                  result[line[0]] = line.split('=')[1]
              print (result)
      return result
  
  print (str2dict("Binary.txt"))
  </code></pre>