It works perfectly in SUM variable in this function def print_direction(): global start_time stack = [] i = end_pos[0] j = end_pos[1]
SUM = int(mat[start_pos[