2

2 つのリストのエントリを比較したい:

例えば:

for key in keys:
        for elem in elements:
            #Find a key in common with 2 lists and write the corresponding value
            if key == elem:
                 do something
            #Iterate through elements unit the current "key" value is found.
            else:
                 pass

この方法の問題は、非常に遅いことです。これを行うためのより速い方法はありますか?

*仮定len(keys) > len(elements)

4

2 に答える 2