You are viewing a single comment's thread. Return to all comments →
I was getting hung up on the addition of -1 untill I saw your example. I basically just merged what you had there into my flat for loop
from collections import defaultdict n, m = map(int, raw_input().split()) d = defaultdict(list) [d[raw_input()].append(i+1) for i in range(n)] for j in [' '.join(map(str, d[raw_input()])) or -1 for i in range(m)]: print j
Seems like cookies are disabled on this browser, please enable them to open this website
DefaultDict Tutorial
You are viewing a single comment's thread. Return to all comments →
I was getting hung up on the addition of -1 untill I saw your example. I basically just merged what you had there into my flat for loop