0
请纠正我的代码通过迭代在Python类变量
PS - 我是相当新的Python
class Contact:
def __init__(self,cid, email):
self.cid=cid
self.email=email
def ind(contacts):
index={}
#Code here
return index
contacts = [Contact(1,'a'),
Contact(2,'b'),
Contact(3,'c'),
Contact(4,'a')]
print(ind(contacts))
需要输出到像 -
{'a':[1,4], 'b':2, 'c':3}