Skip to content

Instantly share code, notes, and snippets.

@abhinavkorpal
Created April 7, 2017 05:35
Show Gist options
  • Save abhinavkorpal/81d731d2fd86d6f8fcee849702cf52ed to your computer and use it in GitHub Desktop.
Save abhinavkorpal/81d731d2fd86d6f8fcee849702cf52ed to your computer and use it in GitHub Desktop.
DefaultDict Tutorial
from collections import defaultdict
d = defaultdict(list)
n, m = list(map(int, raw_input().split()))
for i in range(n):
d[raw_input()].append(i + 1)
for i in range(m):
print(' '.join(map(str, d[raw_input()])) or -1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment