Hi,

I'm trying to write a list of dictionaries like:

people = (
         {'name':'john', 'age':12} ,
         {'name':'kacey', 'age':18}
    )


I've thought the code below would do the task.

But it doesn't work.

And if I "print(people)" what I get is not the organize data structure like
above.

Thanks of any help!
[]s
Gilcan

#!/usr/bin/env python
from collections import defaultdict

person = defaultdict(dict)
people = list()

person['name'] = 'jose'
person['age'] = 12

people.append(person)

person['name'] = 'kacey'
person['age'] = 18

people.append(person)

for person in people:
    print( person['nome'] )
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to