You are viewing a single comment's thread. Return to all comments →
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:
if i in A: for index,j in enumerate(A): if i==j: d[i].append(index+1) else: d[i].append(int(-1))
for values in d.values():
print(*values)
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 →
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():