我有以下列表:
pet = ['cat','dog','fish','cat','fish','fish']
我需要将它转换为这样的字典:
number_pets= {'cat':2, 'dog':1, 'fish':3}
我该怎么做?
python dictionary python-3.x
dictionary ×1
python ×1
python-3.x ×1