(key)
return M
r"""
    7x7 Polybius square.

    Produce the Polybius square for the `7 \times 7` Bifid cipher.
    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...)

    Examples
    ========

    >>> from sympy.crypto.crypto import bifid7_square
    >>> bifid7_square("gold bug")
    Matrix([
    [ G,  O,  L,  D,  B,  U,  A],
    [ C,  E,  F,  H,  I,  J,  K],
    [ M,  N,  P,  Q,  R,  S,  T],
    [ V,  W,  X,  Y,  Z,  0,  1],
    [ 2,  3,  4,  5,  6,  7,  8],
    [ 9, 10, 11, 12, 13, 14, 15],
    [16, 17, 18, 19, 20, 21, 22]])
r"""
    7x7 Polybius square.
r 7x7 Polybius square .
def bifid7_square(key):
    r"""
    7x7 Polybius square.

    Produce the Polybius square for the `7 \times 7` Bifid cipher.
    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...)

    Examples
    ========

    >>> from sympy.crypto.crypto import bifid7_square
    >>> bifid7_square("gold bug")
    Matrix([
    [ G,  O,  L,  D,  B,  U,  A],
    [ C,  E,  F,  H,  I,  J,  K],
    [ M,  N,  P,  Q,  R,  S,  T],
    [ V,  W,  X,  Y,  Z,  0,  1],
    [ 2,  3,  4,  5,  6,  7,  8],
    [ 9, 10, 11, 12, 13, 14, 15],
    [16, 17, 18, 19, 20, 21, 22]])

    """
    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()]
    # create long key
    long_key = key0 + [x for x in A if (not(x in key0))]
    f = lambda i, j: Symbol(long_key[7*i + j])
    M = Matrix(7, 7, f)
    return M
def bifid7_square ( 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 ( ) ] # create long key long_key = key0 + [ x for x in A if ( not ( x in key0 ) ) ] f = lambda i , j : Symbol ( long_key [ 7 * i + j ] ) M = Matrix ( 7 , 7 , f ) return M