私は次のものを持っています:
strlist = ['the', 'the', 'boy', 'happy', 'boy', 'happy']
{x:{(list(enumerate(strlist))[y])[0]} for y in range(len(strlist)) for x in (strlist)}
私の出力は次のとおりです。
{'boy': set([5]), 'the': set([5]), 'happy': set([5])}
私の問題は、これを出力したいということです(python 3.xを使用):
{'boy': {2,4}, 'the': {0,1}, 'happy': {3,5} }
どんな助けでも素晴らしいでしょう!
ありがとう