title: Code Issue in Python
body: <p>I am new to Python ,written simple code for one of my project</p>
  
  <pre><code>argv[1]={"configdatabase":"build1","oltpdatabase":"build1","paymentsdatabase":"build1","yccdatabase":"build1"}   
  argv[2]=test.txt
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>    #!/usr/bin/python
      import json
      import ast
      from sys import argv
      data = argv[1];
      fileName=argv[2];
      data=data.replace("\\","")
      print (data)
      data = json.dumps(data)
      json_to_unicode = json.loads(data)
      unicode_to_dic = ast.literal_eval(json_to_unicode);
      print(type(unicode_to_dic));
      result_dic={};
      data="";
      for k,v in unicode_to_dic.iteritems():
        if v in result_dic.keys():
          data=data.join((result_dic[v],',',k));
          print (data)
          result_dic[v]=data
  
        else:
          result_dic[v]=k;
  
      for key,value in result_dic.iteritems():
        with open(fileName,'a') as the_file:
          the_file.write(key+':'+value+'\n')
  </code></pre>
  
  <p>Expected o/p <code>:build1:configdatabase,oltpdatabase,paymentsdatabase,yccdatabase</code></p>
  
  <p>But getting the output as below:</p>
  
  <pre><code>build1:oltpdatabase,yccdatabaseoltpdatabase,yccdatabase,oltpdatabase,yccdatabasepaymentsdatabaseoltpdatabase,yccdatabaseoltpdatabase,yccdatabase,oltpdatabase,yccdatabasepaymentsdatabase,oltpdatabase,yccdatabaseoltpdatabase,yccdatabase,oltpdatabase,yccdatabasepaymentsdatabaseconfigdatabase
  </code></pre>
  
  <p>Can someone Please help what I am doing wrong here?</p>