title: How to change the Print output of a Pythin dict to Json
body: <p>Hi i'm coming from C# programming and am new to python so i don't really know the Syntax all that well so please forgive me if i did some very stupid rookie mistakes.</p>
  <p>the code i have written so far:</p>
  <pre><code>def main(name):
  filename = &quot;hostname_list.yaml&quot;
  hostname_list = { }
  
  with open(filename) as infile:
      hostname_list = yaml.safe_load(infile)
      json.dumps(infile)
      hostname_list = [s for s in hostname_list['sap_landscape'][name].items()]
  
      print(hostname_list)
  </code></pre>
  <p>it loads a YAML File into a dictionary and then loops over it to find a certain key in the dictionary and then print this key with it's values.</p>
  <p>i get the following output (example output, slightly changed so no data gets compromised):</p>
  <pre><code>[('hostname', 'server3443'), ('SDI', 'T'), ('Type', 'Spo'), ('Land', 'DDD'), ('Severity', 'FTS'), ('Username', None), ('UserID', None), ('Global', None), ('Cycle', 2)]
  </code></pre>
  <p>i need this output now in a JSON Format like this:</p>
  <pre><code>{&quot;hostname&quot;: &quot;server3443&quot;, &quot;SDI&quot;: &quot;T&quot;, &quot;Type&quot;: &quot;Spo&quot;, &quot;Land&quot;: &quot;DDD&quot;, &quot;Severity&quot;: &quot;FTS&quot;, &quot;Username&quot;: None, &quot;UserID&quot;: None, &quot;Global&quot;: null, &quot;Cycle&quot;: 1}
  </code></pre>
  <p>how can i achieve this output? i have been trying to find a solution since about 1,5 weeks now and nothing i tried worked so far and i am quite literally clueless what to do.. .</p>
  <p>Thanks in advance
  Fex</p>