1class Solution:2def uniqueMorseRepresentations(self, words: List[str]) -> int:34# create a dictionary for morse code (You can just copy & paste it! ^.^)5ENG_to_MORSE = {6"a": ".-",7"b": "-...",8"c": "-.-.",9"d": "-..",10"e": ".",11"f": "..-.",12"g": "--.",13"h": "....",14"i": "..",15"j": ".---",16"k": "-.-",17"l": ".-..",18"m": "--",19"n": "-.",20"o": "---",21"p": ".--.",22"q": "--.-",23"r": ".-.",24"s": "...",25"t": "-",26"u": "..-",27"v": "...-",28"w": ".--",29"x": "-..-",30"y": "-.--",31"z": "--..",32}3334cnt = {} # dictionary for different transformations3536for word in words: # loop through every word3738tmp = ""3940for c in word: # loop through every character41tmp += ENG_to_MORSE[c] # convert the word to morse code4243if tmp not in cnt:44cnt[tmp] = 045else:46cnt[tmp] += 14748return len(cnt) # return how many different elements in cnt