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.
- Prepare
- Python
- Collections
- DefaultDict Tutorial
- Discussions
DefaultDict Tutorial
DefaultDict Tutorial
Sort by
recency
|
1084 Discussions
|
Please Login in order to post a comment
from collections import defaultdict n,m,dd = map(int,input().split()),defaultdict(list)
for i in range(n): dd[input()].append(i+1)
for _ in range(m): print(' '.join(map(str,dd.get(input(),[-1]))))
The statement of this problem is so confusing... spent most of my time figure out where does the m and n come from..
Here is my code
What's wrong with below code, why all the test cases are not passing.
from collections import defaultdict
d=defaultdict(list)
A = ['a','b','a','b']
B= ['c']
for i in B:
for values in d.values():