ID_Masterwork = []
def zzip(ID_Master,ID_Masterok):
for i in ID_Masterok:
if ID_Master[i] in result:
if isinstance(result[ID_Master[i]], list):
result[ID_Master[i]].append(i)
else:
result[ID_Master[i]] = [result[ID_Master[i]], i]
else:
result[ID_Master[i]] = i
return result
ID_Mastework = zzip(ID_Master, ID_Masterok)
print("ID_Masterwork= ", ID_Masterwork)