While going through Python course, I came across a question that asked us to find out why this particular code that I have pasted down will cause an error. I ran this code and yet I could find no error . My code ran fine and showed me the output: smallest- 3.
If anyone has more insight on this, please feel free to shoot your thoughts and it would be helpful to me !
smallest = None print("Before:", smallest) for itervar in [3, 41, 12, 9, 74, 15]: if smallest is None or itervar < smallest: smallest = itervar break print("Loop:", itervar, smallest) print("Smallest:", smallest)