I was trying to execute a for loop in Jupyter Notebooks as part of [This exercise].
The context is finding a line of regression by trial and error, but the problem is that the for loop itself seems to simply be ignored.
datapoints = [(1, 2), (2, 0), (3, 4), (4, 4), (5, 3)] smallest_error= float('inf') best_m=0 best_b=0 for m in list(possible_ms): print('The loop is being executed') for b in list(possible_bs): all_error=calculate_all_error(m, b, datapoints) if all_error < smallest_error: print('Found smaller error') smallest_error= all_error best_m=m best_b=b print('Smallest error =', smallest_error) print('m = ', best_m) print('b = ', best_b)
This produces the following output:
Smallest error = inf m = 0 b = 0
As you can see, everything inside the loop has simply done nothing. I have tried resetting the kernel and running all cells, but it didn’t help. There is no error message, so I have no idea what is wrong. Anyone know what the issue is? Thank you in advance.