How to return the row and the column of a table in python?

advertisements

How do I create another function find_letter that will return the row and column of a specific letter? I tried using if(letter in table): but it uses the original table. And if I write if(letter in create_table()): it tells me that the functions are not iterable. I also have no idea how to return the row and column of a given letter.

I gave up on creating a new function to find the row and column so I tried including a code with the create_table function but I am not sure about it.


To find where in your table desired character is, you can just do this. Result is a tuple containing row and column number.

def find_character(target_table, character):
    for row in range(len(target_table)):
        for column in range(len(target_table[row])):
            if target_table[row][column] == character:
                return row,column