title: I am Trying to Save Multiple Dictionaries to a List at a Time Whilst Keeping Their Values, But It Isn't Working
body: <pre><code>itemsInExistence = [{'name': 'Tester', 'stats': 1, 'rank': 1, 'amount': 1}, {'name': 'Mk II Death', 'stats': 10, 'rank': 5, 'amount': 3}]
  def save_list2():
    f = open('all_items.txt', 'w')
    ii = 0
    for item in itemsInExistence:
      print(f.write(itemsInExistence[ii][0], ''))
      f.write(itemsInExistence[ii][1] + ' ')
      f.write(itemsInExistence[ii][2] + ' ') 
      f.write(itemsInExistence[ii][3] + '\n')
      ii += 1
  </code></pre>
  
  <p>Where it says f.write(itemsInExistence[ii][0], '') it is giving me the error</p>
  
  <p>KeyError: 0</p>
  
  <p>Why is this and what does it mean? Is there any way to fix this?</p>