Подскажите что не так
from sys import stdin
d = {}
text = []
for line in stdin:
text.append(line.rstrip('\n'))
for i in text:
name, typ = i.split(': ')
if typ not in d.keys():
mn = set()
mn.add(name)
d[typ] = mn
else:
mn = d[typ]
mn.add(name)
d[typ] = mn
for i in d:
print(i, '- ', end='')
line = list(d[i])
for j in range(len(d[i]) - 1):
print(line[j], end=', ')
print(line[-1])