My question is very simple how can I get the result variable out of this nested loop:
for row in new_matrix:
for col in row:
if col == 'S':
result = [(new_matrix.index(row), row.index(col))]
I tried assigning a global variable result above and set it equal to this expression [(new_matrix.index(row), row.index(col))] but it didn't work, I want to do it without using global because it's bad practice
rowandcolare only defined inside them. The fix is to simply useNoneinstead.