My code is the following:
smallest_so_far = -1
print("Before:", smallest_so_far)
for the_num in [9, 41, 12, 3, 74, 15, -3]:
if the_num < smallest_so_far:
print(the_num, "is smaller than", smallest_so_far)
smallest_so_far = the_num
print(the_num, "is not smaller than", smallest_so_far)
print("After:", smallest_so_far)
But why does it check -3 with -3 again in the end, if it already did one line before? I thought it was supposed to scroll through each and every value inside the "in" once.
Output:
Before: -1
9 is not smaller than -1
41 is not smaller than -1
12 is not smaller than -1
3 is not smaller than -1
74 is not smaller than -1
15 is not smaller than -1
-3 is smaller than -1
-3 is not smaller than -3
After: -3