from collections import defaultdict
tests_dict = {'test 1': ['Manuel', 'Mariana', 'Filipa'], 'test 2': ['Manuel', 'Filipa', 'Mariana'], 'test 3': ['Mariana', 'Manuel', 'Filipa']}
peps_dict = defaultdict(dict)
for test in tests_dict:
for indx, name in enumerate(tests_dict[test], 1):
peps_dict[name][test] = indx
print(peps_dict)
ZnJvbSBjb2xsZWN0aW9ucyBpbXBvcnQgZGVmYXVsdGRpY3QKCnRlc3RzX2RpY3QgPSB7J3Rlc3QgMSc6IFsnTWFudWVsJywgJ01hcmlhbmEnLCAnRmlsaXBhJ10sICd0ZXN0IDInOiBbJ01hbnVlbCcsICdGaWxpcGEnLCAnTWFyaWFuYSddLCAndGVzdCAzJzogWydNYXJpYW5hJywgJ01hbnVlbCcsICdGaWxpcGEnXX0KcGVwc19kaWN0ID0gZGVmYXVsdGRpY3QoZGljdCkKZm9yIHRlc3QgaW4gdGVzdHNfZGljdDoKICAgIGZvciBpbmR4LCBuYW1lIGluIGVudW1lcmF0ZSh0ZXN0c19kaWN0W3Rlc3RdLCAxKToKICAgICAgICBwZXBzX2RpY3RbbmFtZV1bdGVzdF0gPSBpbmR4CnByaW50KHBlcHNfZGljdCk=
defaultdict(<class 'dict'>, {'Mariana': {'test 2': 3, 'test 3': 1, 'test 1': 2}, 'Filipa': {'test 2': 2, 'test 3': 3, 'test 1': 3}, 'Manuel': {'test 2': 1, 'test 3': 2, 'test 1': 1}})