>> i mean for the same key , multiple values. can any1 suggest me how can i
>> do
>> it.....thank you....
>>
>> i tried this, but the old value is replaced by new one, but i want to
>> store
>> al values entered by user.
>> kev = {}
>> if kev.has_key('Name'):
>>        kev['Name'].append(person_name)
>>        print 'name is ', kev['Name']
>> else:
>>        kev['Name'] = [person_name] print "kevin's name is %s" %
>> kev['Name']
>>

I think you want to have a list of names in kev['Name']. In python,
dict has "setdefault" method, which comes handy in this kind of
situations.

kev = {}
kev.setdefault('Name', []).append(person_name) solves your problem.
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to