views:

173

answers:

3

This is the full code:

def checkRow(table, r, pos, word): # done for you!
    for i in range(0, len(word)):
        if table[r][pos+i] != word[i]:
            return False
    return True

I know the bracket mean the index value (in this case r some value of the index table) but what does a bracket next to another bracket mean? (table[r][pos+i])

+1  A: 

It means that the value of table[r] is another array (an array within an array), which you are indexing into with [pos+i]. So it's the equivalent of:

foo = table[r]
if foo[pos+i] != word[i]:
yjerem
Thanks jeremy :)
Jack
A: 

table[r][pos+i]

To get the pos+i character of the string table[r]

Phong
A: 

If r was length 2 and the pos was length 3 the table could be represented this way:

   | pos+0 | pos+1 | pos+2 |
----------------------------
r+0| ???1  | ???2  | ???3  |
----------------------------
r+1| ???4  | ???5  | ???6  |
----------------------------

Where the ??? represent the data at table[r][pos+i].
table[r] returns all values in a row.

Note: Many programming languages don't have an easy way to get columns. IE: C will give an error instead of returning a column when given table[][pos+1].

Jeffery Williams