title: Not able to display json value
body: <p>I have an inventory which I collected from ansible and I'm reading it with python but I have no sucess to print the values here, so I have the following:</p>
  <p>the content below is in a file called &quot;localhost&quot;.</p>
  <pre><code>{
    &quot;ansible_facts&quot;: {
      &quot;facter_architecture&quot;: &quot;x86_64&quot;,
      &quot;facter_bios_release_date&quot;: &quot;12/01/2006&quot;,
      &quot;facter_bios_vendor&quot;: &quot;innotek GmbH&quot;,
      &quot;facter_bios_version&quot;: &quot;VirtualBox&quot;,
      &quot;facter_blockdevice_sda_model&quot;: &quot;VBOX HARDDISK&quot;,
      &quot;facter_blockdevice_sda_size&quot;: 10737418240,
      &quot;facter_blockdevice_sda_vendor&quot;: &quot;ATA&quot;,
      &quot;facter_blockdevice_sr0_model&quot;: &quot;CD-ROM&quot;,
      &quot;facter_blockdevice_sr0_size&quot;: 1073741312,
      &quot;facter_blockdevice_sr0_vendor&quot;: &quot;VBOX&quot;,
      &quot;facter_blockdevices&quot;: &quot;sda,sr0&quot;,
      &quot;facter_boardmanufacturer&quot;: &quot;Oracle Corporation&quot;,
      &quot;facter_boardproductname&quot;: &quot;VirtualBox&quot;,
      &quot;facter_boardserialnumber&quot;: &quot;0&quot;,
      &quot;facter_dhcp_servers&quot;: {
        &quot;enp0s3&quot;: &quot;10.0.2.2&quot;,
        &quot;enp0s8&quot;: &quot;192.168.1.1&quot;,
        &quot;system&quot;: &quot;10.0.2.2&quot;
      },
      &quot;facter_domain&quot;: &quot;home&quot;,
      &quot;facter_facterversion&quot;: &quot;2.4.1&quot;,
      &quot;facter_filesystems&quot;: &quot;xfs&quot;,
      &quot;facter_fqdn&quot;: &quot;mylab.home&quot;,
      &quot;facter_gid&quot;: &quot;root&quot;,
      &quot;facter_hardwareisa&quot;: &quot;x86_64&quot;,
      &quot;facter_hardwaremodel&quot;: &quot;x86_64&quot;,
      &quot;facter_hostname&quot;: &quot;mylab&quot;,
      &quot;facter_id&quot;: &quot;root&quot;,
      &quot;facter_interfaces&quot;: &quot;enp0s3,enp0s8,lo&quot;,
      &quot;facter_ipaddress&quot;: &quot;10.0.2.15&quot;,
      &quot;facter_ipaddress_enp0s3&quot;: &quot;10.0.2.15&quot;,
      &quot;facter_ipaddress_enp0s8&quot;: &quot;192.168.1.101&quot;,
      &quot;facter_ipaddress_lo&quot;: &quot;127.0.0.1&quot;,
      &quot;facter_is_virtual&quot;: true,
      &quot;facter_kernel&quot;: &quot;Linux&quot;,
      &quot;facter_kernelmajversion&quot;: &quot;3.10&quot;,
      &quot;facter_kernelrelease&quot;: &quot;3.10.0-1127.13.1.el7.x86_64&quot;,
      &quot;facter_kernelversion&quot;: &quot;3.10.0&quot;,
      &quot;facter_macaddress&quot;: &quot;08:00:27:dd:47:a8&quot;,
      &quot;facter_macaddress_enp0s3&quot;: &quot;08:00:27:dd:47:a8&quot;,
      &quot;facter_macaddress_enp0s8&quot;: &quot;08:00:27:12:ce:46&quot;,
      &quot;facter_manufacturer&quot;: &quot;innotek GmbH&quot;,
      &quot;facter_memoryfree&quot;: &quot;730.39 MB&quot;,
      &quot;facter_memoryfree_mb&quot;: &quot;730.39&quot;,
      &quot;facter_memorysize&quot;: &quot;990.98 MB&quot;,
      &quot;facter_memorysize_mb&quot;: &quot;990.98&quot;,
      &quot;facter_mtu_enp0s3&quot;: 1500,
      &quot;facter_mtu_enp0s8&quot;: 1500,
      &quot;facter_mtu_lo&quot;: 65536,
      &quot;facter_netmask&quot;: &quot;255.255.255.0&quot;,
      &quot;facter_netmask_enp0s3&quot;: &quot;255.255.255.0&quot;,
      &quot;facter_netmask_enp0s8&quot;: &quot;255.255.255.0&quot;,
      &quot;facter_netmask_lo&quot;: &quot;255.0.0.0&quot;,
      &quot;facter_network_enp0s3&quot;: &quot;10.0.2.0&quot;,
      &quot;facter_network_enp0s8&quot;: &quot;192.168.1.0&quot;,
      &quot;facter_network_lo&quot;: &quot;127.0.0.0&quot;,
      &quot;facter_operatingsystem&quot;: &quot;CentOS&quot;,
      &quot;facter_operatingsystemmajrelease&quot;: &quot;7&quot;,
      &quot;facter_operatingsystemrelease&quot;: &quot;7.8.2003&quot;,
      &quot;facter_os&quot;: {
        &quot;family&quot;: &quot;RedHat&quot;,
        &quot;name&quot;: &quot;CentOS&quot;,
        &quot;release&quot;: {
          &quot;full&quot;: &quot;7.8.2003&quot;,
          &quot;major&quot;: &quot;7&quot;,
          &quot;minor&quot;: &quot;8&quot;
        }
      },
      &quot;facter_osfamily&quot;: &quot;RedHat&quot;,
      &quot;facter_partitions&quot;: {
        &quot;sda1&quot;: {
          &quot;filesystem&quot;: &quot;xfs&quot;,
          &quot;mount&quot;: &quot;/boot&quot;,
          &quot;size&quot;: &quot;2097152&quot;,
          &quot;uuid&quot;: &quot;987fb5e2-f636-423b-997d-c2654993708c&quot;
        },
        &quot;sda2&quot;: {
          &quot;filesystem&quot;: &quot;LVM2_member&quot;,
          &quot;size&quot;: &quot;18872320&quot;
        }
      },
      &quot;facter_path&quot;: &quot;/root/.rbenv/shims:/root/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/bin/python3:/root/bin&quot;,
      &quot;facter_physicalprocessorcount&quot;: 1,
      &quot;facter_processor0&quot;: &quot;Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz&quot;,
      &quot;facter_processorcount&quot;: 1,
      &quot;facter_processors&quot;: {
        &quot;count&quot;: 1,
        &quot;models&quot;: [
          &quot;Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz&quot;
        ],
        &quot;physicalcount&quot;: 1
      },
      &quot;facter_productname&quot;: &quot;VirtualBox&quot;,
      &quot;facter_ps&quot;: &quot;ps -ef&quot;,
      &quot;facter_rubyplatform&quot;: &quot;x86_64-linux&quot;,
      &quot;facter_rubysitedir&quot;: &quot;/usr/local/share/ruby/site_ruby/&quot;,
      &quot;facter_rubyversion&quot;: &quot;2.0.0&quot;,
      &quot;facter_selinux&quot;: false,
      &quot;facter_serialnumber&quot;: &quot;0&quot;,
      &quot;facter_sshecdsakey&quot;: &quot;AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBE8u+HCceoSA9mrw1oboY4sAXhkgp4CBTe8QjuW2OAeYIQS7LblPztfQmJFkXpHTWhLvSBYglzcuZiJOzUbZQ/0=&quot;,
      &quot;facter_sshed25519key&quot;: &quot;AAAAC3NzaC1lZDI1NTE5AAAAIDutjvzHFEKqc0bprmbkm9ZUoADflkan6dnCVcYsGOTT&quot;,
      &quot;facter_sshfp_ecdsa&quot;: &quot;SSHFP 3 1 2190a1073f110b50ed6fb912cd04144603a85098\nSSHFP 3 2 3a708ee555593b0ad5a2f1992ae949d56d2f3556c37b201ef683d4a3ea850660&quot;,
      &quot;facter_sshfp_ed25519&quot;: &quot;SSHFP 4 1 695978669c105b4a3a06c4b9a685020363b72c67\nSSHFP 4 2 794f24ad5bd7b91a1d3a0f484ceb166088ac8d57e3e1682e8b8fe006fde1c169&quot;,
      &quot;facter_sshfp_rsa&quot;: &quot;SSHFP 1 1 07afd9583d0785ac923230bef3b0d0ffeefad097\nSSHFP 1 2 29158514b311cc7687fa1c3aab1fa1abee0f2f581eb3d607a6b4ffb8ff258d59&quot;,
      &quot;facter_sshrsakey&quot;: &quot;AAAAB3NzaC1yc2EAAAADAQABAAABAQCtgyTEG+VnEnXiiaP4tFpIiWwWfqxdW8BCATa5W9QE0AsfY1OiFoLRXYGqhL72q0N+VTHQGB7eB1sd9Nas48erDzZXpgLoIDqM1pa/vT/j/SygQB2rwgo2wga0tw+zW1cw+sELjXHAYsi8DADKbGlX2cCeT3MKeWdkg+BQogf74Sy4NEPbYhILXPfvt3cJxCM02sIn/eQL+n06iSzesUIEy5n+AlRgACR3zHnk5rtHipj/RzmPv+J0V3du7+g6/3TiKDcBTNHtb8QSa4DSGkmbW7Wdhvnw9GyhO5ySGB2G3rmLiVIm9vdjB9L/X/L2g8TB5+/dO52UxUSX17nwzuJB&quot;,
      &quot;facter_swapfree&quot;: &quot;1024.00 MB&quot;,
      &quot;facter_swapfree_mb&quot;: &quot;1024.00&quot;,
      &quot;facter_swapsize&quot;: &quot;1024.00 MB&quot;,
      &quot;facter_swapsize_mb&quot;: &quot;1024.00&quot;,
      &quot;facter_system_uptime&quot;: {
        &quot;days&quot;: 0,
        &quot;hours&quot;: 3,
        &quot;seconds&quot;: 12984,
        &quot;uptime&quot;: &quot;3:36 hours&quot;
      },
      &quot;facter_timezone&quot;: &quot;CEST&quot;,
      &quot;facter_type&quot;: &quot;Other&quot;,
      &quot;facter_uniqueid&quot;: &quot;000a0f02&quot;,
      &quot;facter_uptime&quot;: &quot;3:36 hours&quot;,
      &quot;facter_uptime_days&quot;: 0,
      &quot;facter_uptime_hours&quot;: 3,
      &quot;facter_uptime_seconds&quot;: 12984,
      &quot;facter_uuid&quot;: &quot;b64ed9b0-7168-4e49-a34a-90e6ea6f751a&quot;,
      &quot;facter_virtual&quot;: &quot;kvm&quot;
    },
    &quot;changed&quot;: false
  }
  </code></pre>
  <p>I have the following code.
  I tried a lot of deferents stuffs, but somehow it complains about <code>&quot;list indices must be integers or slices, not str&quot;</code></p>
  <pre><code>import json
  
  dict = []
  with open('localhost', 'r') as jsonfile:
      myfile = json.load(jsonfile)
  
  
  result = json.dumps(myfile, indent=2, sort_keys=True)
  dict.append(result)
  
  print(dict['ansible_facts'])
  </code></pre>
  <p>From this list I need to extract
  <strong>facter_system_uptime</strong> and <strong>facter_hostname</strong> only but I had no success.</p>
  <p>I tried to put in a loop, but still same issue.</p>
  <pre><code>for data in dict['ansible_facts']:
      print(data)
  </code></pre>
  <p>What's wrong here?</p>