strlist = ['the', 'the', 'boy', 'happy', 'boy', 'happy']
print(dict(((string, set(i for i,w in enumerate(strlist) if w == string)) for string in strlist)))
c3RybGlzdCA9IFsndGhlJywgJ3RoZScsICdib3knLCAnaGFwcHknLCAnYm95JywgJ2hhcHB5J10KcHJpbnQoZGljdCgoKHN0cmluZywgc2V0KGkgZm9yIGksdyBpbiBlbnVtZXJhdGUoc3RybGlzdCkgaWYgdyA9PSBzdHJpbmcpKSBmb3Igc3RyaW5nIGluIHN0cmxpc3QpKSkK