human
Convert a Mobile Numeric Keypad sequence to equivalent sentence | Function to convert mobile numeric keypad sequence into its equivalent string.
Store the mobile keypad mappings.
Traverse the str1ing str1.
If the current character is ' . ' , then continue to the next iteration.
Stores the number of continuous clicks.
Iterate a loop to find the count of same characters.
2 , 3 , 4 , 5 , 6 and 8 keys will have maximum of 3 letters.
7 and 9 keys will have maximum of 4 keys.
Handle the end condition.
Check if the current pressed key is 7 or 9.
Else , the key pressed is either 2 , 3 , 4 , 5 , 6 or 8.
Driver Code"
How can the above be solved in Python?

What is a code to convert a Mobile Numeric Keypad sequence to equivalent sentence and the other steps required?
assistant
#Here is code to convert a Mobile Numeric Keypad sequence to equivalent sentence and the other steps required.
 def printSentence ( str1 ) :
	nums = [ " " , " " , " ABC " , " DEF " , " GHI " , " JKL " , " MNO " , " PQRS " , " TUV " , " WXYZ " ]
	i = 0
	while ( i < len ( str1 ) ) :
		if ( str1 [ i ] == ' . ' ) :
			i += 1
			continue
		count = 0
		while ( i + 1 < len ( str1 ) and str1 [ i + 1 ] and str1 [ i ] == str1 [ i + 1 ] ) :
			if ( count == 2 and ( ( str1 [ i ] >= '2' and str1 [ i ] <= '6' ) or ( str1 [ i ] == '8' ) ) ) :
				break
			elif ( count == 3 and ( str1 [ i ] == '7' or str1 [ i ] == '9' ) ) :
				break
			count += 1
			i += 1
			if ( i < len ( str ) ) :
				break
		if ( str1 [ i ] == '7' or str1 [ i ] == '9' ) :
			print ( nums [ ord ( str1 [ i ] ) - 48 ] [ count % 4 ] , end = " " )
		else :
			print ( nums [ ord ( str1 [ i ] ) - 48 ] [ count % 3 ] , end = " " )
		i += 1
if __name__ == ' _ _ main _ _ ' :
	str1 = "234"
	printSentence ( str1 )