class Solution:
def uniqueMorseRepresentations(self, words):
"""
:type words: List[str]
:rtype: int
"""
# creat two lists for mapping later
aphabet_list = ['a','b','c','d','e','f','g'
,'h','i','j','k','l','m','n'
,'o','p','q','r','s','t','u'
,'v','w','x','y','z']
morse_list = [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
list_trans = []
# loop through words and transform the words
for word in words:
trans = ''
for c in word:
trans += morse_list[aphabet_list.index(c)]
list_trans.append(trans)
list_remove_repeat = set(list_trans) # use set() to remove the duplicate element
return len(list_remove_repeat)