October 20th, 2013, 02:18 PM
Join Date: Oct 2013
Time spent in forums: 58 m 46 sec
Reputation Power: 0
Help with matrices??
I have to write a function called find_chars_reverse that, given a matrix as an input argument, must do the following things:
Scan the matrix from the bottom-right to the upper left corner in row order and,
Return a string composed by the concatenation of the strings contained in the matrix elements.
Scanning the matrix from the bottom-right to the upper left corner in row order means that, if the matrix has M rows and N columns, the function must:
First, scan the elements in row M, then those in row M-1, up to row 0; and
For each row, scan the element from the Nth to the 0th column.
Here is the code I have written. There are other functions I must write for this project that I am having the same problem with. The problem I am having is telling the program to discern between integers and strings. The program should only return strings, but the matrix contains integers which the program must bypass. By the way, the input argument is the matrix=m.
for i in range(row-1,-1,-1):
for j in range(col-1,-1,-1):
The code above works, but returns integers which have been converted to string.
I have tried numerous different ways of writing the line: if m[i][j]!=type(int) - such as: if m[i][j]==type(str):.
So, my question is how would I return only strings?