(pt, key)
return ct
r"""
    Performs the Bifid cipher encryption on plaintext ``pt``, and returns the ciphertext.

    This is the version of the Bifid cipher that uses the `7 \times 7` Polybius square.
    Assumes alphabet of symbols is "A", ..., "Z", "0", ..., "22".
    (Also, assumes you have some way of distinguishing "22"
    from "2", "2" juxtaposed together for deciphering...)

    INPUT:

        ``pt``: plaintext string (digits okay)

        ``key``: short string for key (no repetitions, digits okay)

    OUTPUT:

        ciphertext from Bifid7 cipher (all caps, no spaces)

    Examples
    ========

    >>> from sympy.crypto.crypto import encipher_bifid7
    >>> key = "encrypt"
    >>> pt = "meet me on monday at 8am"
    >>> encipher_bifid7(pt, key)
    'JEJJLNAA3ME19YF3J222R'
r"""
    Performs the Bifid cipher encryption on plaintext ``pt``, and returns the ciphertext.
r Performs the Bifid cipher encryption on plaintext pt and returns the ciphertext .
def encipher_bifid7(pt, key):
    r"""
    Performs the Bifid cipher encryption on plaintext ``pt``, and returns the ciphertext.

    This is the version of the Bifid cipher that uses the `7 \times 7` Polybius square.
    Assumes alphabet of symbols is "A", ..., "Z", "0", ..., "22".
    (Also, assumes you have some way of distinguishing "22"
    from "2", "2" juxtaposed together for deciphering...)

    INPUT:

        ``pt``: plaintext string (digits okay)

        ``key``: short string for key (no repetitions, digits okay)

    OUTPUT:

        ciphertext from Bifid7 cipher (all caps, no spaces)

    Examples
    ========

    >>> from sympy.crypto.crypto import encipher_bifid7
    >>> key = "encrypt"
    >>> pt = "meet me on monday at 8am"
    >>> encipher_bifid7(pt, key)
    'JEJJLNAA3ME19YF3J222R'

    """
    A = alphabet_of_cipher() + [str(a) for a in range(23)]
    # first make sure the letters are capitalized
    # and text has no spaces
    key = uniq(key)
    key0 = [x.capitalize() for x in key if x.isalnum()]
    pt0 = [x.capitalize() for x in pt if x.isalnum()]
    # create long key
    long_key = key0 + [x for x in A if not(x in key0)]
    n = len(pt0)
    # the fractionalization
    pairs = [[long_key.index(x)//7, long_key.index(x) % 7] for x in pt0]
    tmp_cipher = flatten([x[0] for x in pairs] + [x[1] for x in pairs])
    ct = "".join([long_key[7*tmp_cipher[2*i] + tmp_cipher[2*i + 1]] for i in range(n)])
    return ct
def encipher_bifid7 ( pt , key ) : A = alphabet_of_cipher ( ) + [ str ( a ) for a in range ( 23 ) ] # first make sure the letters are capitalized # and text has no spaces key = uniq ( key ) key0 = [ x . capitalize ( ) for x in key if x . isalnum ( ) ] pt0 = [ x . capitalize ( ) for x in pt if x . isalnum ( ) ] # create long key long_key = key0 + [ x for x in A if not ( x in key0 ) ] n = len ( pt0 ) # the fractionalization pairs = [ [ long_key . index ( x ) // 7 , long_key . index ( x ) % 7 ] for x in pt0 ] tmp_cipher = flatten ( [ x [ 0 ] for x in pairs ] + [ x [ 1 ] for x in pairs ] ) ct = "" . join ( [ long_key [ 7 * tmp_cipher [ 2 * i ] + tmp_cipher [ 2 * i + 1 ] ] for i in range ( n ) ] ) return ct