Suppose we are given a String
"AABCD"
with length n = 5, from an alphabet
{'A', 'B', 'C', 'D', 'E', 'F'}
with dimension len(alphabet) = 6. What is a Pythonic way of converting this string to a 5 x 6 matrix?
ie.
#INPUT:
string = "AABCD"
alphabet = {'A', 'B', 'C', 'D', 'E', 'F'}
#OUTPUT
output =
A B C D E F
char 1[ 1 0 0 0 0 0 ]
char 2[ 1 0 0 0 0 0 ]
char 3[ 0 1 0 0 0 0 ]
char 4[ 0 0 1 0 0 0 ]
char 5[ 0 0 0 1 0 0 ]
I scoured other answers but have yet to find a question that is similar. Suggestions greatly appreciated!