We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
A lot of people seem to be having trouble with this challege so I thought I would post my working code. Any suggestions for improvement are welcome!
from collections import defaultdict
d = defaultdict(list)
list1=[]
n, m = map(int,raw_input().split())
for i in range(0,n):
d[raw_input()].append(i+1)
for i in range(0,m):
list1=list1+[raw_input()]
for i in list1:
if i in d:
print " ".join( map(str,d[i]) )
else:
print -1
DefaultDict Tutorial
You are viewing a single comment's thread. Return to all comments →
A lot of people seem to be having trouble with this challege so I thought I would post my working code. Any suggestions for improvement are welcome!