Difference between Python2 and Python3 while using map with find and index
问题 Given a pattern and a string str , find if str follows the same pattern. Here follows means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str . Examples: pattern = "abba" , str = "dog cat cat dog" should return true; dog is a , cat is b and the words form the abba pattern. pattern = "abba" , str = "dog cat cat fish" should return false; the string follows a abbc pattern instead. My solution works in Python 2: def wordPattern(self, pattern,