I have a dictionary and I want to get a list of all the values and one more. So I did something like this
new_val = 'v3' test = {'k1': 'v1', 'k2': 'v2'} l = test.values (). New_val)
However when I do this, l = none
. But if I use an intermediate
l = test.values (), l.append (new_val)
l < / Code> What I need in it The first method works.
l = test.values (). The attachment (new_val) l
is none because the return value of .append ()
(which you can call l
) function.
l = test.values () l.append (new_val)
This works because you make a copy first A new value for test.values ()
and entering it into l
, and then l
Add
l = test.values () x = l.append (new_val)
then also x
Is none
Comments
Post a Comment