Rene Pijlman wrote: > Yves Glodt: >> I seem to be unable to find a way to appends more keys/values to the end >> of a dictionary > > A dictionary has no order, and therefore no end.
that means I can neither have a dictionary with 2 identical keys but different values...? I would need e.g. this: (a list of ports and protocols, to be treated later in a loop) ports = {'5631': 'udp', '5632': 'tcp', '3389': 'tcp', '5900': 'tcp'} #then: for port,protocol in ports.iteritems(): ________print port,protocol ________#do more stuff What would be the appropriate pythonic way of doing this? >> mydict = {'a':'1'} >> >> I need to append 'b':'2' to it to have: >> >> mydict = {'a':'1','b':'2'} >> >> How to do? > > Like this: > >>>> mydict = {'a':'1'} >>>> mydict['b'] = '2' >>>> print mydict > {'a': '1', 'b': '2'} >>>> {'a': '1', 'b': '2'} == {'b': '2', 'a': '1'} > True > -- http://mail.python.org/mailman/listinfo/python-list