Suppose i have a matrix like this
table = [
# grid: 4 by 9
['A','B','C','D'],
['E','F','G','H'],
['I','J','K','L'],
['M','N','O','P'],
['Q','R','S','T'],
['U','V','W','X'],
['Y','Z','1','2'],
['3','4','5','5'],
['7','8','9','0'],
]
If i want to print the the string thats two down on the third column(2x,3y) resulting in G. Or something along the lines. How do i tell python that it should be a grid? And how do i return list information, the table.find(something) did not work (saying table has no find attribute) Im fairly new to python. I have searched the internet, with not much help..
edit: I must be doing something wrong?
table = [
# grid: 4 by 9
# 1 2 3 4
['A','B','C','D'],#1
['E','F','G','H'],#2
['I','J','K','L'],#3
['M','N','O','P'],#4
['Q','R','S','T'],#5
['U','V','W','X'],#6
['Y','Z','1','2'],#7
['3','4','5','5'],#8
['7','8','9','0'],#9
]
print table[1][2], table[4][3]
Prints O and T.
O is right, but T is not, thats row 5 isnt it?’
I’m trying to write a text positional encryption algorithm with text matrixes, like one of the famous ciphers( i cant remember the name of).
I want to apply the said printing of each letter to the text that is caught by raw_input, i used dictionaries before, but i want to try this row/column method if possible, it will be much harder to break.
List indexing starts at zero, so for example a fourth element in a list has index 3. You can define a helper function to get items/columns by their “actual position”.
As for your edit,
table[1][2]should printG, notOandtable[4][3]rightly returnsT.