def wordPattern(pattern, s):
dict1 = {}
dict2 = {}
for key,value in enumerate(list(s.split(" "))):
if value not in dict1:
dict1[value]= [key]
else:
dict1[value].append(key)
for key,value in enumerate(pattern):
if value not in dict2:
dict2[value]= [key]
else:
dict2[value].append(key)
return (list(dict1.values()) == list(dict2.values()))