I'm creating a class search program that accepts a keyword and searches it through the description elements of a class.
Im trying to get result[[]] to return the whole list(r) but it only returns the rest of list(r) after the search term. I don't understand why r would change because of the if statement.
table_row_col is a 2d array in [class][description elements] format and search term is a string.
def search_class(search_term, table_row_col):
result = [[]]
row = 0
for r in table_row_col:
for c in r:
if search_term in c:
result.insert(row, list(r))
row += 1
return result
Example result: Keyword 'Poly' result = [In-Person TR 01:40 PM 02:55 PM WNS 506 Schmitt, J]
Rather then
[MATH 09001 Polynomial equations In-Person TR 01:40 PM 02:55 PM WNS 506 Schmitt, J]
When I put the result.insert statement outside the if loop then the whole class description is printed
Any help would be greatly appreciated. It's my first time using python and I'm still adjusting to the for loops.