Polybius Square Cipher | function to display polybius cipher text ; convert each character to its encrypted code ; finding row of the table ; finding column of the table ; if character is 'k ; if character is greater than 'j ; Driver 's Code ; print the cipher of " geeksforgeeks "
def polybiusCipher ( s ) : NEW_LINE INDENT for char in s : NEW_LINE INDENT row = int ( ( ord ( char ) - ord ( ' a ' ) ) / 5 ) + 1 NEW_LINE col = ( ( ord ( char ) - ord ( ' a ' ) ) % 5 ) + 1 NEW_LINE DEDENT DEDENT ' NEW_LINE INDENT if char == ' k ' : NEW_LINE INDENT row = row - 1 NEW_LINE col = 5 - col + 1 NEW_LINE DEDENT DEDENT ' NEW_LINE INDENT elif ord ( char ) >= ord ( ' j ' ) : NEW_LINE INDENT if col == 1 : NEW_LINE INDENT col = 6 NEW_LINE row = row - 1 NEW_LINE DEDENT col = col - 1 NEW_LINE DEDENT print ( row , col , end = ' ' , sep = ' ' ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s = " geeksforgeeks " NEW_LINE polybiusCipher ( s ) NEW_LINE DEDENT