human
Count distinct strings possible by replacing each character by its Morse code | Function to count unique array elements by replacing each character by its Morse code.
Stores Morse code of all lowercase characters.
Stores distinct elements of String by replacing each character by Morse code.
Stores length of arr array.
Traverse the array.
Stores the Morse code of arr [ i ].
Stores length of current String.
Update temp.
Insert temp into st.
Return count of elements in the set.
Driver code"
How can the above be solved in Python?
 Write me a code to count distinct strings possible by replacing each character by its Morse code and the other steps required?
assistant
#Here is code to count distinct strings possible by replacing each character by its Morse code and the other steps required.
 def uniqueMorseRep ( arr ) :
	morseCode = [ " . - " , " - . . . " , " - . - . " , " - . . " , " . " , " . . - . " , " - - . " , " . . . . " , " . . " , " . - - - " , " - . - " , " . - . . " , " - - " , " - . " , " - - - " , " . - - . " , " - - . - " , " . - . " , " . . . " , " - " , " . . - " , " . . . - " , " . - - " , " - . . - " , " - . - - " , " - - . . " ] ;
	st = set ( ) ;
	N = len ( arr ) ;
	for i in range ( N ) :
		temp = " " ;
		M = len ( arr [ i ] ) ;
		for j in range ( M ) :
			temp += morseCode [ ord ( arr [ i ] [ j ] ) - ord ( ' a ' ) ] ;
		st . add ( temp ) ;
	return len ( st ) ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ " gig " , " zeg " , " gin " , " msn " ] ;
	print ( uniqueMorseRep ( arr ) , " " ) ;