appending to dict
bucket79
bucket79 at daum.net
Fri May 14 05:40:00 EDT 2004
Hi
is there anyway appending to dictionary?
list has this feature
>>>a = []
>>>a.append(1)
>>>print a
[1]
but dictionary can't
i wanna do like this thing
>>>a = {1, 2}
>>>a.append(3, 4) -> This is just my idea :@
>>>print a
{1:2, 3:4}
so i try this feature like
>>>a = {1, 2}
>>>a = dict(zip(a.keys().append(3), a.values().append(4)))
but this make's error
because a.keys().append(3) makes 'None' (i can't understand this :( )
so i try
>>>import copy
>>>a = dict(zip(copy.copy(a.keys()).append(3),
copy.copy(a.values()).append(4)))
and
a = dict(zip(copy.deepcopy(a.keys()).append(3),
copy.deepcopy(a.values()).append(4)))
but this make's error, too
why a.keys().append(3) makes 'None' ?
and is there anyway appending to dictionary?
any post will be appreciated :)
More information about the Python-list
mailing list