Saturday, 24 August 2013

Dictionary with multiple string values for a key

Dictionary with multiple string values for a key

I need a dictionary that is composed by a lot of keys, and the values must
be a list that contains lots of strings. (in Python) I tried:
d1[key].append(value), but Python says : AttributeError: 'str' object has
no attribute 'append'. I need something like :
{a:[b,c,d,e],b:[t,r,s,z]....} What could I do?
thanks in advance.

No comments:

Post a Comment