title: How to save and open nested lists and dictionaries in text file?
body: <p>I am new at Python and I dont know what would be the best way to approuch this problem:
  I want to save nested lists in python as strings in a text file and then be able to load the information from the text file.</p>
  
  <p>I would like to do something like that keeping in mind that the list and the dic are two random examples, the solution needs to be general.</p>
  
  <p>This is how I would save it:</p>
  
  <pre class="lang-py prettyprint-override"><code>
  list = ["29", "24", "33", "34", ["25", "2" ,"3", "14", "79"], ["0", "26"]]
  dict = {'A' : ["25", "2" ,"3", "14", "79"], 'B' : ["0", "26"], 'C' : ["0", "26", "33"]}
  f = open("doc.txt","w")
  f.write(str(dict)+"\n")
  f.write(str(list))
  f.close()
  </code></pre>
  
  <p>Then I would like to read the lines of the text file and load back the information they store like that but with the correct data type.</p>
  
  <pre class="lang-py prettyprint-override"><code>f = open("doc.txt","r")
  content = f.read()
  dic, list = content.split("\n")
  f.close()
  </code></pre>