<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 06/18/2015 10:57 AM, Gilcan Machado
      wrote:<br>
    </div>
    <blockquote
cite="mid:CACUcfw3b1s5fhmFR+6+1Jk5LbeCw7eRxA6e5QyyYitgxOiaJCg@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div dir="ltr">
        <div>
          <div>Hi,<br>
            <br>
          </div>
          I'm trying to write a list of dictionaries like:<br>
          <br>
        </div>
        people = (<br>
                 {'name':'john', 'age':12} ,<br>
                 {'name':'kacey', 'age':18} <br>
            )<br>
        <div>
          <div><br>
            <br>
          </div>
          <div>I've thought the code below would do the task.<br>
            <br>
          </div>
          <div>But it doesn't work.<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Never say "it doesn't work" on this list.  Tell us what it did, and
    what you expected.  Provide a copy of the full error message. 
    That's much more helpful than making us guess.<br>
    <br>
    <blockquote
cite="mid:CACUcfw3b1s5fhmFR+6+1Jk5LbeCw7eRxA6e5QyyYitgxOiaJCg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div><br>
          </div>
          <div>And if I "print(people)" what I get is not the organize
            data structure like above.<br>
          </div>
          <div><br>
          </div>
          <div>Thanks of any help!<br>
          </div>
          <div>[]s<br>
          </div>
          <div>Gilcan<br>
          </div>
          <div><br>
          </div>
          <div>#!/usr/bin/env python<br>
          </div>
          <div>from collections import defaultdict<br>
            <br>
            person = defaultdict(dict)<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    If you want *two* different dictionaries, you'll have to create
    *two* of them.  You code creates only this one.<br>
    <br>
    <blockquote
cite="mid:CACUcfw3b1s5fhmFR+6+1Jk5LbeCw7eRxA6e5QyyYitgxOiaJCg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>people = list() <br>
            <br>
            person['name'] = 'jose'<br>
            person['age'] = 12<br>
            <br>
            people.append(person)<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Here's where you need to create the second one.<br>
    <br>
    <blockquote
cite="mid:CACUcfw3b1s5fhmFR+6+1Jk5LbeCw7eRxA6e5QyyYitgxOiaJCg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div><br>
            person['name'] = 'kacey'<br>
            person['age'] = 18<br>
            <br>
            people.append(person)<br>
            <br>
            for person in people:<br>
                print( person['nome'] )<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Typo here:  'name', not 'nome'.<br>
    <br>
    <blockquote
cite="mid:CACUcfw3b1s5fhmFR+6+1Jk5LbeCw7eRxA6e5QyyYitgxOiaJCg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div><br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418
</pre>
  </body>
</html>