def anagramQuestion(list1, input):; G# X1 J, u, [* z7 O, L
dict1 = {}
9 x' l5 c2 b8 B, _* W for x in range(0,len(list1)):
/ Y( |2 V; E+ M( k! ] key = ''.join(sorted(list1[x]))
7 X& U. P" k. `+ p if key in dict1:6 ?5 f! `1 u& S2 [
dict1[key].append(list1[x])' e( Q1 o: r+ H. U1 h$ @, r, D! }" C j
else:
b6 ]8 [% x/ M# B/ b dict1[key] = [list1[x]]; i, B# V [, r! ]' {4 @2 g8 L
result = []# ~3 [! W4 o& H( M
for x in dict1:+ {. X3 J! L. x/ o
inputsorted = ''.join(sorted(input)); ~' I1 V' @. B O' G* J( S0 s
if x == inputsorted:
) ?( F) X0 u( E9 u dict1[x].remove(input)9 s, N( f8 q$ i1 c2 O# P
result.append(dict1[x])+ A+ u ~0 o, ]7 @4 ]
, F8 N' p, P7 d) s return result
|